From: Ulya Trofimovich Date: Wed, 8 May 2019 10:01:48 +0000 (+0100) Subject: Inlined closure cleanup in the pruning procedure to further speedup determinization. X-Git-Tag: 1.2~72 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4f0c2bce301616cb4046e76fb565f83b59893683;p=re2c Inlined closure cleanup in the pruning procedure to further speedup determinization. --- diff --git a/src/dfa/closure.cc b/src/dfa/closure.cc index c3b7ba51..42d68acc 100644 --- a/src/dfa/closure.cc +++ b/src/dfa/closure.cc @@ -141,6 +141,9 @@ void prune(ctx_t &ctx) for (i = b; i != e; ++i) { nfa_state_t *s = i->state; + + closure_cleanup(s); + if (s->type == nfa_state_t::RAN) { buffer.push_back(*i); } diff --git a/src/dfa/closure_leftmost.h b/src/dfa/closure_leftmost.h index 90d8acd7..d830378e 100644 --- a/src/dfa/closure_leftmost.h +++ b/src/dfa/closure_leftmost.h @@ -7,16 +7,12 @@ namespace re2c { +template void closure_cleanup(nfa_state_t *q); template static void closure_leftmost_dfs(ctx_t &ctx); inline void closure_leftmost(ldetctx_t &ctx) { closure_leftmost_dfs(ctx); - - // cleanup - for (clositer_t i = ctx.state.begin(); i != ctx.state.end(); ++i) { - i->state->clos = NOCLOS; - } } template @@ -54,6 +50,12 @@ void closure_leftmost_dfs(ctx_t &ctx) } } +template<> +inline void closure_cleanup(nfa_state_t *q) +{ + q->clos = NOCLOS; +} + } // namespace re2c #endif // _RE2C_DFA_CLOSURE_LEFTMOST_ diff --git a/src/dfa/closure_posix.h b/src/dfa/closure_posix.h index 86d2a879..ffaea282 100644 --- a/src/dfa/closure_posix.h +++ b/src/dfa/closure_posix.h @@ -19,6 +19,7 @@ namespace re2c * can just propagate the new path up to the next join point. */ +template void closure_cleanup(nfa_state_t *q); template static void closure_posix_gor1(ctx_t &); template static void closure_posix_gtop(ctx_t &); @@ -41,15 +42,6 @@ inline void closure_posix(pdetctx_t &ctx) } DDUMP_CLSTATS(ctx); - - // cleanup - closure_t &cl = ctx.state; - for (clositer_t i = cl.begin(); i != cl.end(); ++i) { - nfa_state_t *q = i->state; - q->clos = NOCLOS; - q->arcidx = 0; - DASSERT(q->status == GOR_NOPASS && q->active == 0); - } } template @@ -307,6 +299,14 @@ void relax_gtop(ctx_t &ctx, const typename ctx_t::conf_t &c) } } +template<> +inline void closure_cleanup(nfa_state_t *q) +{ + q->clos = NOCLOS; + q->arcidx = 0; + DASSERT(q->status == GOR_NOPASS && q->active == 0); +} + } // namespace re2c #endif // _RE2C_DFA_CLOSURE_POSIX_