roseTestLeftfix: unify common "nfa is dead" code

This commit is contained in:
Justin Viiret 2016-02-11 13:54:51 +11:00 committed by Matthew Barr
parent 996eba9686
commit fb8747295e

View File

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