[Mew-dist 10279] Re: Japanese nickname in Addrbook

sen_ml at example.com sen_ml at example.com
1999年 8月 20日 (金) 15:40:27 JST


From: SAKAI Kiyotaka <ksakai at example.com>
Subject: [Mew-dist 10269] Re: Japanese nickname in Addrbook
date: Fri, 20 Aug 1999 14:46:34 +0900

ksakai> IM の初期の頃の議論で $&, $`, $' をプログラム中で 1回でも使用すると、
ksakai> パターンマッチごとに $&, $`, $' に対応する文字列をコピーして持つように
ksakai> なるためパフォーマンスが悪くなるという話だったので、$&, $`, $' は敢え
ksakai> て使わないようになっていたのですが、実際のところ、どうなんでしょうね。

perlvar(1p) に

$&      The string matched by the last successful pattern
        ...       

        The use of this variable anywhere in a program
        imposes a considerable performance penalty on all
        regular expression matches.  See the
        Devel::SawAmpersand module from CPAN for more
        information.

と書いてあるので、CPAN をみに行きました。

ftp://ftp.lab.kdd.co.jp/pub/CPAN/modules/by-module/Devel/ の下に
Devel-SawAmpersand-0.20.readme というファイルがあり、その中に

    There's a global variable in the perl source, called sawampersand. It
    gets set to true in that moment in which the parser sees one of $`, $',
    and $&. It never can be set to false again. Trying to set it to false
    breaks the handling of the $`, $&, and $' completely.

    If the global variable `sawampersand' is set to true, all subsequent RE
    operations will be accompanied by massive in-memory copying, because
    there is nobody in the perl source who could predict, when the
    (necessary) copy for the ampersand family will be needed. So all
    subsequent REs are considerable slower than necessary.

と書いてありました。Workaround 等についても記されているので、興味がある人は
みてみるといいかも。

# performance に関する numeric な話がないですね。



Mew-dist メーリングリストの案内