This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
pp_entersub(): simplify autoload logic
authorDavid Mitchell <davem@iabyn.com>
Sat, 11 Jul 2015 14:37:11 +0000 (15:37 +0100)
committerDavid Mitchell <davem@iabyn.com>
Wed, 3 Feb 2016 08:59:36 +0000 (08:59 +0000)
eliminate a label and goto by by just setting cv to null on failure,
and have a single "if (!cv) croak()" test at the end of the loop.

pp_hot.c

index 9891aec..f9a40fd 100644 (file)
--- a/pp_hot.c
+++ b/pp_hot.c
@@ -3450,20 +3450,15 @@ PP(pp_entersub)
        /* should call AUTOLOAD now? */
        else {
           try_autoload:
-           if ((autogv = gv_autoload_pvn(GvSTASH(gv), GvNAME(gv), GvNAMELEN(gv),
-                                  GvNAMEUTF8(gv) ? SVf_UTF8 : 0)))
-           {
-               cv = GvCV(autogv);
-           }
-           else {
-              sorry:
-               sub_name = sv_newmortal();
-               gv_efullname3(sub_name, gv, NULL);
-               DIE(aTHX_ "Undefined subroutine &%"SVf" called", SVfARG(sub_name));
-           }
-       }
-       if (!cv)
-           goto sorry;
+           autogv = gv_autoload_pvn(GvSTASH(gv), GvNAME(gv), GvNAMELEN(gv),
+                                  GvNAMEUTF8(gv) ? SVf_UTF8 : 0);
+            cv = autogv ? GvCV(autogv) : NULL;
+       }
+       if (!cv) {
+            sub_name = sv_newmortal();
+            gv_efullname3(sub_name, gv, NULL);
+            DIE(aTHX_ "Undefined subroutine &%"SVf" called", SVfARG(sub_name));
+        }
     }
 
     if (UNLIKELY(CvCLONE(cv) && ! CvCLONED(cv)))