summaryrefslogtreecommitdiff
path: root/pad.h
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2014-11-30 08:19:59 -0800
committerFather Chrysostomos <sprout@cpan.org>2014-11-30 10:41:50 -0800
commit3bc8ec963e9657121e69386195faa61e46928dda (patch)
tree887662c05e68d577a50d4d57abe45edfd579c5d2 /pad.h
parent38ee69105d2f617842b1cefef001fd6f3c2369b2 (diff)
downloadperl-3bc8ec963e9657121e69386195faa61e46928dda.tar.gz
Fix qr/@array(?{block})/
For qr/(?{})/ to work closurewise, it has to have an implicit anony- mous sub that the blocks run in. To that end, the parser compiles the entire thing in the context of a new anonymous sub. For a run-time, pattern (with @a or $b outside the block), since the ops have been compiled in the context of that anonymous sub, they must be run within it, too (otherwise the ops point to the wrong pad), so at compile time the ‘arguments’ to qr are turned into a call to an anonymous sub that looks like like sub { @a, "(?{...})", ...}. This was causing a bizarre copy: $ perl5.18.1 -e 'qr/@a(?{})/' Bizarre copy of ARRAY in subroutine exit at -e line 1. Bisect points to v5.17.10-92-g491453b: $ ../perl.git/Porting/bisect.pl --target=miniperl --start=v5.14.0 --end=v5.18.1 -e 'BEGIN{$^H|=0x00200000} qr/@a(?{})/' ... 491453ba443e114f751f325a4734b3d07b897606 is the first bad commit commit 491453ba443e114f751f325a4734b3d07b897606 Author: David Mitchell <davem@iabyn.com> Date: Wed Apr 17 17:51:16 2013 +0100 Handle /@a/ array expansion within regex engine The array op was not being flagged as a flattening op, and sub exit was trying to copy an unflattened array. We don’t want the array flattened. To allow it to pass through sub exit unscathed, we need to make this an lvalue sub. That fixes it and everything just works. It even makes non-array cases slightly faster, because nothing is copied at sub exit now: before$ time ./miniperl -e 'qr/$a(?{})/ for 1..1000000' real 0m3.321s user 0m3.312s sys 0m0.006s after$ time ./miniperl -e 'qr/$a(?{})/ for 1..1000000' real 0m2.855s user 0m2.845s sys 0m0.006s
Diffstat (limited to 'pad.h')
0 files changed, 0 insertions, 0 deletions