From 58004f15f044a28617ada1af3c9e83909c8e5e3f Mon Sep 17 00:00:00 2001 From: Justin Viiret Date: Fri, 14 Jul 2017 12:54:03 +1000 Subject: [PATCH] limex_compile: turn tugs into a bitset --- src/nfa/limex_compile.cpp | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/nfa/limex_compile.cpp b/src/nfa/limex_compile.cpp index 94d9961b..1c56b312 100644 --- a/src/nfa/limex_compile.cpp +++ b/src/nfa/limex_compile.cpp @@ -144,13 +144,15 @@ struct build_info { const map &rsmi, const map &smi, const map> &ti, const set &zi, - bool dai, bool sci, const CompileContext &cci, - u32 nsi) - : h(hi), state_ids(states_in), repeats(ri), tops(ti), zombies(zi), - do_accel(dai), stateCompression(sci), cc(cci), + bool dai, bool sci, const CompileContext &cci, u32 nsi) + : h(hi), state_ids(states_in), repeats(ri), tops(ti), tugs(nsi), + zombies(zi), do_accel(dai), stateCompression(sci), cc(cci), num_states(nsi) { for (const auto &br : repeats) { - insert(&tugs, br.tug_triggers); + for (auto v : br.tug_triggers) { + assert(state_ids.at(v) != NO_STATE); + tugs.set(state_ids.at(v)); + } br_cyclic[br.cyclic] = BoundedRepeatSummary(br.repeatMin, br.repeatMax); } @@ -170,7 +172,7 @@ struct build_info { map squashMap; const map> &tops; - unordered_set tugs; + NFAStateSet tugs; map br_cyclic; const set &zombies; bool do_accel; @@ -1528,7 +1530,7 @@ bool isExceptionalTransition(const NGHolder &h, const NFAEdge &e, } // All transitions out of a tug trigger are exceptional. - if (contains(args.tugs, from)) { + if (args.tugs.test(f)) { return true; } return false; @@ -1845,10 +1847,9 @@ struct Factory { maskSetBit(limex->repeatCyclicMask, cyclic); } /* also include tugs in repeat cyclic mask */ - for (NFAVertex v : args.tugs) { - u32 v_state = args.state_ids.at(v); - assert(v_state != NO_STATE); - maskSetBit(limex->repeatCyclicMask, v_state); + for (size_t i = args.tugs.find_first(); i != args.tugs.npos; + i = args.tugs.find_next(i)) { + maskSetBit(limex->repeatCyclicMask, i); } }