diff options
author | Father Chrysostomos <sprout@cpan.org> | 2014-11-07 21:46:58 -0800 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2014-11-08 00:33:02 -0800 |
commit | d8cdf5739e500a4f72aa611694308d7244c29573 (patch) | |
tree | 652494e1385679221ab2551bb565fd2304cfd5c5 /lib | |
parent | 12cea2fa656447eef8848bac6de2e3fe413eb787 (diff) | |
download | perl-d8cdf5739e500a4f72aa611694308d7244c29573.tar.gz |
Allow OPpTARGET_MY optimisation for split
Many operators have a special SV allocated in the pad which is used
for return values (the target). If we make that pad offset point to
a lexical variable, then we can optimise, say, $lexical = "$foo" into
just "$foo", where $lexical is stringify’s ‘target’. And pp_stringify
doesn’t need to know any better. We already do that for many ops.
This is safe to extend to split. split only uses its target in this
code at the end:
GETTARGET;
PUSHi(iters);
so there is no danger of modifying its argument before reading it.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/B/Deparse.pm | 3 | ||||
-rw-r--r-- | lib/B/Op_private.pm | 2 |
2 files changed, 4 insertions, 1 deletions
diff --git a/lib/B/Deparse.pm b/lib/B/Deparse.pm index 47ca02cf11..a8782fbb24 100644 --- a/lib/B/Deparse.pm +++ b/lib/B/Deparse.pm @@ -5002,6 +5002,9 @@ sub pp_qr { matchop(@_, "qr", "") } sub pp_runcv { unop(@_, "__SUB__"); } sub pp_split { + maybe_targmy(@_, \&split); +} +sub split { my $self = shift; my($op, $cx) = @_; my($kid, @exprs, $ary, $expr); diff --git a/lib/B/Op_private.pm b/lib/B/Op_private.pm index 6dfebdb737..7fc1de662e 100644 --- a/lib/B/Op_private.pm +++ b/lib/B/Op_private.pm @@ -144,7 +144,7 @@ $bits{$_}{7} = 'OPpPV_IS_UTF8' for qw(dump goto last next redo); $bits{$_}{6} = 'OPpREFCOUNTED' for qw(leave leaveeval leavesub leavesublv leavewrite); $bits{$_}{6} = 'OPpRUNTIME' for qw(match pushre qr subst substcont); $bits{$_}{2} = 'OPpSLICEWARNING' for qw(aslice hslice padav padhv rv2av rv2hv); -$bits{$_}{4} = 'OPpTARGET_MY' for qw(abs add atan2 chdir chmod chomp chown chr chroot concat cos crypt divide exec exp flock getpgrp getppid getpriority hex i_add i_divide i_modulo i_multiply i_negate i_postdec i_postinc i_subtract index int kill left_shift length link log match mkdir modulo multiply oct ord pow push rand rename repeat right_shift rindex rmdir schomp setpgrp setpriority sin sleep sqrt srand stringify subst subtract symlink system time trans transr unlink unshift utime vec wait waitpid); +$bits{$_}{4} = 'OPpTARGET_MY' for qw(abs add atan2 chdir chmod chomp chown chr chroot concat cos crypt divide exec exp flock getpgrp getppid getpriority hex i_add i_divide i_modulo i_multiply i_negate i_postdec i_postinc i_subtract index int kill left_shift length link log match mkdir modulo multiply oct ord pow push rand rename repeat right_shift rindex rmdir schomp setpgrp setpriority sin sleep split sqrt srand stringify subst subtract symlink system time trans transr unlink unshift utime vec wait waitpid); $bits{$_}{5} = 'OPpTRANS_COMPLEMENT' for qw(trans transr); $bits{$_}{7} = 'OPpTRANS_DELETE' for qw(trans transr); $bits{$_}{0} = 'OPpTRANS_FROM_UTF' for qw(trans transr); |