summaryrefslogtreecommitdiff
path: root/op.c
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2014-11-06 10:28:02 -0800
committerFather Chrysostomos <sprout@cpan.org>2014-11-06 13:15:36 -0800
commit6a9665b0cf31b4cabf408a0590e598f3ec785780 (patch)
tree5316b71407345a45531fce01e7769645ee33c209 /op.c
parent890b5089ee2bba7607f5a69cd8d7c260fac77cf0 (diff)
downloadperl-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.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/op.c b/op.c
index 1b24320f20..2619e2748f 100644
--- a/op.c
+++ b/op.c
@@ -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