This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
regcomp.c: regpiece: swap order of conditionals
authorKarl Williamson <khw@cpan.org>
Mon, 5 Oct 2020 04:15:17 +0000 (22:15 -0600)
committerKarl Williamson <khw@cpan.org>
Mon, 12 Oct 2020 15:45:47 +0000 (09:45 -0600)
Its a bit more clearer to test the 0 case before the 1 case, and by
doing so it becomes visually easier to compare and contrast the the two
cases.

regcomp.c

index 47e1e28..a5fdcc4 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -12769,12 +12769,7 @@ S_regpiece(pTHX_ RExC_state_t *pRExC_state, I32 *flagp, U32 depth)
     /* 'SIMPLE' operands don't require full generality */
     if ((flags&SIMPLE)) {
         if (max == REG_INFTY) {
-            if (min == 1) {
-                reginsert(pRExC_state, PLUS, ret, depth+1);
-                MARK_NAUGHTY(3);
-                goto done_main_op;
-            }
-            else if (min == 0) {
+            if (min == 0) {
                 if (UNLIKELY(RExC_pm_flags & PMf_WILDCARD)) {
                     goto min0_maxINF_wildcard_forbidden;
                 }
@@ -12783,6 +12778,11 @@ S_regpiece(pTHX_ RExC_state_t *pRExC_state, I32 *flagp, U32 depth)
                 MARK_NAUGHTY(4);
                 goto done_main_op;
             }
+            else if (min == 1) {
+                reginsert(pRExC_state, PLUS, ret, depth+1);
+                MARK_NAUGHTY(3);
+                goto done_main_op;
+            }
         }
 
         /* Here, SIMPLE, but not the '*' and '+' special cases */