This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
rpeep: maintain chain when del extra nextstates
authorDavid Mitchell <davem@iabyn.com>
Wed, 9 Dec 2015 13:51:22 +0000 (13:51 +0000)
committerDavid Mitchell <davem@iabyn.com>
Wed, 9 Dec 2015 14:29:35 +0000 (14:29 +0000)
There's code in rpeep() that eliminates duplicate nextstate ops.
E.g.

    FOO -> NEXTSTATE1 -> NULL -> ... -> NULL -> NEXTSTATE2 -> ...

becomes

    FOO --------------------------------------> NEXTSTATE2 -> ...

This code didn't leave oldoldop -> oldop -> o as a consistent chain of
adjacent op_next ops.

op.c

diff --git a/op.c b/op.c
index bc6263b..07a9121 100644 (file)
--- a/op.c
+++ b/op.c
@@ -13448,9 +13448,10 @@ Perl_rpeep(pTHX_ OP *o)
                    op_null(o);
                    if (oldop)
                        oldop->op_next = nextop;
+                    o = nextop;
                    /* Skip (old)oldop assignment since the current oldop's
                       op_next already points to the next op.  */
-                   continue;
+                   goto redo;
                }
            }
            break;