From 885183b1ded1b5ad4c168feaca06b4dbf6723545 Mon Sep 17 00:00:00 2001 From: Ulya Trofimovich Date: Thu, 7 Feb 2019 21:41:18 +0000 Subject: [PATCH] Small speedup in determinization by delaying computation of costly conditions. --- re2c/src/dfa/closure.cc | 6 ++---- re2c/src/dfa/find_state.cc | 4 ++-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/re2c/src/dfa/closure.cc b/re2c/src/dfa/closure.cc index 1ed21f4d..f5620ef6 100644 --- a/re2c/src/dfa/closure.cc +++ b/re2c/src/dfa/closure.cc @@ -180,10 +180,8 @@ void generate_versions(determ_context_t &ctx) const tagver_t *vs = tvtbl[c->tvers]; for (size_t t = 0; t < ntag; ++t) { const Tag &tag = tags[t]; - const tagver_t - h0 = thist.last(h, t), - l0 = thist.last(l, t); + const tagver_t h0 = thist.last(h, t); if (h0 == TAGVER_ZERO) continue; const tagver_t v = history(tag) ? vs[t] : TAGVER_ZERO; @@ -193,7 +191,7 @@ void generate_versions(determ_context_t &ctx) m = newvers.insert(std::make_pair(x, n)).first->second; if (n == m) ++maxver; - if (!fixed(tag) && (l0 == TAGVER_ZERO || history(tag))) { + if (!fixed(tag) && (history(tag) || thist.last(l, t) == TAGVER_ZERO)) { newacts.insert(std::make_pair(x, m)); } } diff --git a/re2c/src/dfa/find_state.cc b/re2c/src/dfa/find_state.cc index deeca51b..d4010e0e 100644 --- a/re2c/src/dfa/find_state.cc +++ b/re2c/src/dfa/find_state.cc @@ -408,8 +408,8 @@ bool kernel_map_t::operator()(const kernel_t *x, const kernel_t *y) for (size_t t = 0; t < ntag; ++t) { // see note [mapping ignores items with lookahead tags] - if (ctx.dc_taghistory.last(xl, t) != TAGVER_ZERO - && !history(tags[t])) continue; + if (!history(tags[t]) + && ctx.dc_taghistory.last(xl, t) != TAGVER_ZERO) continue; const tagver_t xv = xvs[t], yv = yvs[t]; tagver_t &xv0 = y2x[yv], &yv0 = x2y[xv]; -- 2.40.0