develooper Front page | perl.perl5.porters | Postings from February 2003

Re: [perl #20683] [fix] /(??{$x})/ ignore any changes made to $x

Thread Previous | Thread Next
Enache Adrian
February 23, 2003 18:36
Re: [perl #20683] [fix] /(??{$x})/ ignore any changes made to $x
Message ID:
On Mon, Feb 24, 2003 at 02:06:38AM +0000, wrote:
> Precompiling the returned patterns bypasses the (obviously buggy)
> optimisation altogether. I think it might make most sense to remove
> the optimisation and document this as the recommended approach.

The optimization seems to be valuable even in simple, un-branched
cases, so why not keep it in ?

$ dd if=/dev/zero count=4096 | time perl -ne '$a=1; m/(??{ $a })/'

3.96user 0.00system 0:03.98elapsed 99%CPU (0avgtext+0avgdata 0maxresident)k
( optimized )
55.04user 0.01system 0:55.08elapsed 99%CPU (0avgtext+0avgdata 0maxresident)k
( unoptimized )

Notice that my patch ( the second variant ) doesn't affect the rest
of the code in way: the only drawback is the bloat of this little
magic_setregexp() function.

Of course, it's always better to precompile its regexp's and to
avoid (??{ .. }) altogether.

But why forcing a speed regression, even for weird cases ?



Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About