This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
pp_grepwhile: no need to extend the stack
authorDavid Mitchell <davem@iabyn.com>
Sat, 15 Jul 2017 21:26:04 +0000 (22:26 +0100)
committerDavid Mitchell <davem@iabyn.com>
Thu, 27 Jul 2017 10:30:24 +0000 (11:30 +0100)
when returning from grep in scalar context, no need to extend the stack by
one when pushing the result count, since the last grep iteration will have
pushed its result which we've just popped.

pp_hot.c

index c580f26..4c391f7 100644 (file)
--- a/pp_hot.c
+++ b/pp_hot.c
@@ -3579,10 +3579,10 @@ PP(pp_grepwhile)
        SP = PL_stack_base + POPMARK;           /* pop original mark */
        if (gimme == G_SCALAR) {
             if (PL_op->op_private & OPpTRUEBOOL)
-                XPUSHs(items ? &PL_sv_yes : &PL_sv_zero);
+                PUSHs(items ? &PL_sv_yes : &PL_sv_zero);
             else {
                dTARGET;
-               XPUSHi(items);
+               PUSHi(items);
             }
        }
        else if (gimme == G_ARRAY)