From 99c8f462f49adae5501b0c9e190423cd29bde857 Mon Sep 17 00:00:00 2001 From: Matthew Horsfall Date: Sat, 14 Dec 2013 22:25:22 -0500 Subject: [PATCH] Also optimise returning lists: 'return ($one, $two);' --- op.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/op.c b/op.c index a9dafaa..9c3cc94 100644 --- a/op.c +++ b/op.c @@ -11140,11 +11140,19 @@ Perl_rpeep(pTHX_ OP *o) && OP_TYPE_IS(sibling->op_next->op_next, OP_LEAVESUB) && cUNOPx(sibling)->op_first == next && next->op_sibling && next->op_sibling->op_next - && next->op_sibling->op_next == sibling - && next->op_next && sibling->op_next) - { - next->op_sibling->op_next = sibling->op_next; - o->op_next = next->op_next; + && next->op_next + ) { + /* Look through the PUSHMARK's siblings for one that + * points to the RETURN */ + OP *top = next->op_sibling; + while (top && top->op_next) { + if (top->op_next == sibling) { + top->op_next = sibling->op_next; + o->op_next = next->op_next; + break; + } + top = top->op_sibling; + } } } -- 2.7.4