This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
pp_entersub(): eliminate a label
authorDavid Mitchell <davem@iabyn.com>
Sat, 11 Jul 2015 14:30:38 +0000 (15:30 +0100)
committerDavid Mitchell <davem@iabyn.com>
Wed, 3 Feb 2016 08:59:36 +0000 (08:59 +0000)
replace:

  retry:
    if (A) die;
    if (B) {
        ...;
        goto retry;
    }

with

    while (B) {
        ...;
    }

    if (A) die;

it's functionally equivalent except that the A test is now only
tried after we have been successful at B. This is ok, because
A is testing for an uncloned closure prototype, while B is looking
for a CV stub which needs autoloading,and it doesn't rally matter
which we test for first.

pp_hot.c

index 66aea46..9891aec 100644 (file)
--- a/pp_hot.c
+++ b/pp_hot.c
@@ -3431,10 +3431,7 @@ PP(pp_entersub)
 
     ENTER;
 
-  retry:
-    if (UNLIKELY(CvCLONE(cv) && ! CvCLONED(cv)))
-       DIE(aTHX_ "Closure prototype called");
-    if (UNLIKELY(!CvROOT(cv) && !CvXSUB(cv))) {
+    while (UNLIKELY(!CvROOT(cv) && !CvXSUB(cv))) {
        GV* autogv;
        SV* sub_name;
 
@@ -3467,9 +3464,11 @@ PP(pp_entersub)
        }
        if (!cv)
            goto sorry;
-       goto retry;
     }
 
+    if (UNLIKELY(CvCLONE(cv) && ! CvCLONED(cv)))
+       DIE(aTHX_ "Closure prototype called");
+
     if (UNLIKELY((PL_op->op_private & OPpENTERSUB_DB) && GvCV(PL_DBsub)
             && !CvNODEBUG(cv)))
     {