diff options
author | Father Chrysostomos <sprout@cpan.org> | 2014-11-06 10:28:02 -0800 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2014-11-06 13:15:36 -0800 |
commit | 6a9665b0cf31b4cabf408a0590e598f3ec785780 (patch) | |
tree | 5316b71407345a45531fce01e7769645ee33c209 /op.c | |
parent | 890b5089ee2bba7607f5a69cd8d7c260fac77cf0 (diff) | |
download | perl-6a9665b0cf31b4cabf408a0590e598f3ec785780.tar.gz |
Optimise substr assignment at sub exit
The assignment in substr(...) = ... gets optimised away in void con-
text. We can also optimise it away at sub exit as long as this is not
an lvalue sub and pp_substr returns the replacement when optimised.
Diffstat (limited to 'op.c')
-rw-r--r-- | op.c | 7 |
1 files changed, 6 insertions, 1 deletions
@@ -12653,7 +12653,12 @@ Perl_rpeep(pTHX_ OP *o) break; case OP_SASSIGN: - if (OP_GIMME(o,0) == G_VOID) { + if (OP_GIMME(o,0) == G_VOID + || ( o->op_next->op_type == OP_LINESEQ + && ( o->op_next->op_next->op_type == OP_LEAVESUB + || ( o->op_next->op_next->op_type == OP_RETURN + && !CvLVALUE(PL_compcv))))) + { OP *right = cBINOP->op_first; if (right) { /* sassign |