summaryrefslogtreecommitdiff
path: root/op.c
diff options
context:
space:
mode:
authorDave Mitchell <davem@fdisolutions.com>2004-05-22 11:15:34 +0000
committerDave Mitchell <davem@fdisolutions.com>2004-05-22 11:15:34 +0000
commitdb7511dbe8b6c31eca42cd71bbe3853dbf1d748b (patch)
treeb9e04dc31eb56b6bc412786fd543be589d6718af /op.c
parent42975ef9995a99592a4475f9992c94ccb4ff52ab (diff)
downloadperl-db7511dbe8b6c31eca42cd71bbe3853dbf1d748b.tar.gz
[perl #29790] Optimization busted: '@a = "b", sort @a' drops "b"
Fix the sort-in-place optimization of change #22349. p4raw-link: @22349 on //depot/perl: fe1bc4cf71e7b04d33e679798964a090d9fa7b46 p4raw-id: //depot/perl@22839
Diffstat (limited to 'op.c')
-rw-r--r--op.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/op.c b/op.c
index bdc3426819..cdc074903e 100644
--- a/op.c
+++ b/op.c
@@ -6642,6 +6642,17 @@ Perl_peep(pTHX_ register OP *o)
|| (o2->op_flags & OPf_WANT) != OPf_WANT_VOID)
break;
+ /* check that the sort is the first arg on RHS of assign */
+
+ o2 = cUNOPx(o2)->op_first;
+ if (!o2 || o2->op_type != OP_NULL)
+ break;
+ o2 = cUNOPx(o2)->op_first;
+ if (!o2 || o2->op_type != OP_PUSHMARK)
+ break;
+ if (o2->op_sibling != o)
+ break;
+
/* check the array is the same on both sides */
if (oleft->op_type == OP_RV2AV) {
if (oright->op_type != OP_RV2AV