]> git.ipfire.org Git - thirdparty/vectorscan.git/commitdiff
roseTestLeftfix: unify common "nfa is dead" code
authorJustin Viiret <justin.viiret@intel.com>
Thu, 11 Feb 2016 02:54:51 +0000 (13:54 +1100)
committerMatthew Barr <matthew.barr@intel.com>
Tue, 1 Mar 2016 00:34:57 +0000 (11:34 +1100)
src/rose/program_runtime.h

index 7702e737b4d42a1e52ad350726625de7ab16a063..b45607e2764a65a4dd877df539ed2fbf1c96eeb4 100644 (file)
@@ -439,9 +439,7 @@ char roseTestLeftfix(const struct RoseEngine *t, struct hs_scratch *scratch,
         if (left->infix) {
             if (infixTooOld(q, loc)) {
                 DEBUG_PRINTF("infix %u died of old age\n", ri);
-                scratch->tctxt.groups &= left->squash_mask;
-                mmbit_unset(activeLeftArray, arCount, ri);
-                return 0;
+                goto nfa_dead;
             }
 
             reduceQueue(q, loc, left->maxQueueLen, q->nfa->maxWidth);
@@ -449,9 +447,7 @@ char roseTestLeftfix(const struct RoseEngine *t, struct hs_scratch *scratch,
 
         if (!rosePrefixCheckMiracles(t, left, ci, q, end)) {
             DEBUG_PRINTF("leftfix %u died due to miracle\n", ri);
-            scratch->tctxt.groups &= left->squash_mask;
-            mmbit_unset(activeLeftArray, arCount, ri);
-            return 0;
+            goto nfa_dead;
         }
 
 #ifdef DEBUG
@@ -463,10 +459,7 @@ char roseTestLeftfix(const struct RoseEngine *t, struct hs_scratch *scratch,
         char rv = nfaQueueExecRose(q->nfa, q, leftfixReport);
         if (!rv) { /* nfa is dead */
             DEBUG_PRINTF("leftfix %u died while trying to catch up\n", ri);
-            mmbit_unset(activeLeftArray, arCount, ri);
-            assert(!mmbit_isset(activeLeftArray, arCount, ri));
-            scratch->tctxt.groups &= left->squash_mask;
-            return 0;
+            goto nfa_dead;
         }
 
         // Queue must have next start loc before we call nfaInAcceptState.
@@ -482,6 +475,11 @@ char roseTestLeftfix(const struct RoseEngine *t, struct hs_scratch *scratch,
         DEBUG_PRINTF("leftfix done %hhd\n", (signed char)rv);
         return rv;
     }
+
+nfa_dead:
+    mmbit_unset(activeLeftArray, arCount, ri);
+    scratch->tctxt.groups &= left->squash_mask;
+    return 0;
 }
 
 static rose_inline