This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
pp_entersub(): reduce scope of gimme
authorDavid Mitchell <davem@iabyn.com>
Mon, 13 Jul 2015 15:18:55 +0000 (16:18 +0100)
committerDavid Mitchell <davem@iabyn.com>
Wed, 3 Feb 2016 08:59:37 +0000 (08:59 +0000)
Only calculate the gimme var where its needed.

pp_hot.c

index 0796e56..d54b882 100644 (file)
--- a/pp_hot.c
+++ b/pp_hot.c
@@ -3364,7 +3364,6 @@ PP(pp_entersub)
     GV *gv;
     CV *cv;
     PERL_CONTEXT *cx;
-    I32 gimme;
     I32 old_savestack_ix;
 
     if (UNLIKELY(!sv))
@@ -3512,14 +3511,13 @@ PP(pp_entersub)
            DIE(aTHX_ "No DB::sub routine defined");
     }
 
-    gimme = GIMME_V;
-
     if (!(CvISXSUB(cv))) {
        /* This path taken at least 75% of the time   */
        dMARK;
        PADLIST * const padlist = CvPADLIST(cv);
         I32 depth;
         bool hasargs;
+        I32 gimme;
 
         /* keep PADTMP args alive throughout the call (we need to do this
          * because @_ isn't refcounted). Note that we create the mortals
@@ -3538,6 +3536,7 @@ PP(pp_entersub)
            }
         }
 
+        gimme = GIMME_V;
        PUSHBLOCK(cx, CXt_SUB, MARK);
         hasargs = cBOOL(PL_op->op_flags & OPf_STACKED);
        PUSHSUB(cx);
@@ -3658,7 +3657,7 @@ PP(pp_entersub)
        CvXSUB(cv)(aTHX_ cv);
 
        /* Enforce some sanity in scalar context. */
-       if (gimme == G_SCALAR) {
+       if (GIMME_V == G_SCALAR) {
             SV **svp = PL_stack_base + markix + 1;
             if (svp != PL_stack_sp) {
                 *svp = svp > PL_stack_sp ? &PL_sv_undef : *PL_stack_sp;