regcomp.c: Move clause of while() conditional into loop
authorKarl Williamson <khw@cpan.org>
Mon, 3 Dec 2018 00:45:06 +0000 (17:45 -0700)
committerKarl Williamson <khw@cpan.org>
Sat, 8 Dec 2018 04:12:16 +0000 (21:12 -0700)
This is in preparation for making the conditional more complicated than
can be easily done in the condition.

regcomp.c

index 1c7063c..300c608 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -3957,9 +3957,9 @@ S_join_exact(pTHX_ RExC_state_t *pRExC_state, regnode *scan,
 
     /* Look through the subsequent nodes in the chain.  Skip NOTHING, merge
      * EXACT ones that are mergeable to the current one. */
-    while (n
-           && (PL_regkind[OP(n)] == NOTHING
-               || (stringok && OP(n) == OP(scan)))
+    while (    n
+           && (    PL_regkind[OP(n)] == NOTHING
+               || (stringok && PL_regkind[OP(n)] == EXACT))
            && NEXT_OFF(n)
            && NEXT_OFF(scan) + NEXT_OFF(n) < I16_MAX)
     {
@@ -3987,6 +3987,10 @@ S_join_exact(pTHX_ RExC_state_t *pRExC_state, regnode *scan,
             if (oldl + STR_LEN(n) > U8_MAX)
                 break;
 
+            if (OP(scan) != OP(n)) {
+                break;
+            }
+
             DEBUG_PEEP("merg", n, depth, 0);
             merged++;