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

Re: [perl #20683] [fix] Better Patch

Thread Previous | Thread Next
From:
hv
Date:
February 25, 2003 18:47
Subject:
Re: [perl #20683] [fix] Better Patch
Message ID:
200302260249.h1Q2nBU16391@crypt.compulink.co.uk
Enache Adrian <enache@rdslink.ro> wrote:
:> The example could be rewritten:
:> 
:> #! /usr/bin/perl
:> $p=1;
:> foreach (1,2,3,4) {
:> 	$p++ if /(??{ $p })/;
:> }
:> print $p;
:> __END__
:> 
:> this prints 2, not 5.
:
:My previous patch has the drawback of dropping the optimization even
:in simple cases where $p is a regular variable, and it's just accessed,
:not modified.
:
:The modified version works as follows:
:  - only a magic_setregexp() method is added to 'r'-magical variables,
:    method which calls sv_unmagic(sv,'r'), forcing recompilation if
:    the variable is set.
:  - if the variable has some 'get' magic methods, it isn't made
:    'r'-magical in the first place (regexec.c ~ 2900)
:  - if the variable gets some 'get' magic methods since it was cached,
:    (ex. it is tied) its 'r' magic is dropped (regexec.c ~2876)
:
:I added 2 two tests to op/pat.t, too.

Thanks, applied as #18782.

Hugo

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About