This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
In pp_match, refactor the call to CALLREGEXEC() to avoid a goto.
authorNicholas Clark <nick@ccl4.org>
Thu, 16 Jun 2011 09:11:39 +0000 (11:11 +0200)
committerNicholas Clark <nick@ccl4.org>
Thu, 16 Jun 2011 09:16:54 +0000 (11:16 +0200)
The previous slightly contorted logic had an if() block that ended in a goto,
where the target was only 6 lines later, and could not be reached directly.
It dates back to (at least) 5.000, with no structural changes since then.

pp_hot.c

index 6adb5be..526adb8 100644 (file)
--- a/pp_hot.c
+++ b/pp_hot.c
@@ -1404,22 +1404,18 @@ PP(pp_match)
             && !SvROK(TARG))   /* Cannot trust since INTUIT cannot guess ^ */
            goto yup;
     }
             && !SvROK(TARG))   /* Cannot trust since INTUIT cannot guess ^ */
            goto yup;
     }
-    if (CALLREGEXEC(rx, (char*)s, (char *)strend, (char*)truebase,
-                    minmatch, TARG, NUM2PTR(void*, gpos), r_flags))
-    {
-       PL_curpm = pm;
-       if (dynpm->op_pmflags & PMf_ONCE) {
+    if (!CALLREGEXEC(rx, (char*)s, (char *)strend, (char*)truebase,
+                    minmatch, TARG, NUM2PTR(void*, gpos), r_flags))
+       goto ret_no;
+
+    PL_curpm = pm;
+    if (dynpm->op_pmflags & PMf_ONCE) {
 #ifdef USE_ITHREADS
 #ifdef USE_ITHREADS
-            SvREADONLY_on(PL_regex_pad[dynpm->op_pmoffset]);
+       SvREADONLY_on(PL_regex_pad[dynpm->op_pmoffset]);
 #else
 #else
-           dynpm->op_pmflags |= PMf_USED;
+       dynpm->op_pmflags |= PMf_USED;
 #endif
 #endif
-        }
-       goto gotcha;
     }
     }
-    else
-       goto ret_no;
-    /*NOTREACHED*/
 
   gotcha:
     if (rxtainted)
 
   gotcha:
     if (rxtainted)