peephole optimise op_other branch in OP_ARGDEFELEM
authorDavid Mitchell <davem@iabyn.com>
Mon, 1 Aug 2016 10:06:14 +0000 (11:06 +0100)
committerDavid Mitchell <davem@iabyn.com>
Wed, 3 Aug 2016 19:54:41 +0000 (20:54 +0100)
I forgot to do this earlier.

op.c
t/perf/opcount.t

diff --git a/op.c b/op.c
index 6b5ef81..e611dbe 100644 (file)
--- a/op.c
+++ b/op.c
@@ -14169,6 +14169,7 @@ Perl_rpeep(pTHX_ OP *o)
        case OP_DORASSIGN:
        case OP_RANGE:
        case OP_ONCE:
+       case OP_ARGDEFELEM:
            while (cLOGOP->op_other->op_type == OP_NULL)
                cLOGOP->op_other = cLOGOP->op_other->op_next;
            DEFER(cLOGOP->op_other);
index 13c916d..3cdd334 100644 (file)
@@ -20,7 +20,7 @@ BEGIN {
 use warnings;
 use strict;
 
-plan 2250;
+plan 2251;
 
 use B ();
 
@@ -266,3 +266,16 @@ test_opcount(0, 'barewords can be constant-folded',
              {
                  concat => 0,
              });
+
+{
+    no warnings 'experimental::signatures';
+    use feature 'signatures';
+
+    my @a;
+    test_opcount(0, 'signature default expressions get optimised',
+                 sub ($s = $a[0]) {},
+                 {
+                     aelem         => 0,
+                     aelemfast_lex => 1,
+                 });
+}