Extremely minor pp_goto optimization
authorSteffen Mueller <smueller@cpan.org>
Wed, 6 Mar 2013 17:42:17 +0000 (18:42 +0100)
committerSteffen Mueller <smueller@cpan.org>
Wed, 6 Mar 2013 17:52:48 +0000 (18:52 +0100)
Makes use of the fact that the exception case is both rare and okay to
be penalized (a tiny bit) instead of the common case doing an extra
branch.

pp_ctl.c

index 616c7c1..c9d833f 100644 (file)
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -2803,13 +2803,13 @@ PP(pp_goto)
            SvREFCNT_inc_simple_void(cv); /* avoid premature free during unwind */
            FREETMPS;
            cxix = dopoptosub(cxstack_ix);
-           if (cxix < 0)
-           {
-               SvREFCNT_dec(cv);
-               DIE(aTHX_ "Can't goto subroutine outside a subroutine");
-           }
-           if (cxix < cxstack_ix)
+           if (cxix < cxstack_ix) {
+                if (cxix < 0) {
+                    SvREFCNT_dec(cv);
+                    DIE(aTHX_ "Can't goto subroutine outside a subroutine");
+                }
                dounwind(cxix);
+            }
            TOPBLOCK(cx);
            SPAGAIN;
            /* ban goto in eval: see <20050521150056.GC20213@iabyn.com> */