From d232b58df8409fce4ed739df132110591081e90d Mon Sep 17 00:00:00 2001 From: Samuel Luptak Date: Tue, 26 Nov 2024 20:49:27 +0100 Subject: [PATCH] reduced binary searches --- src/nfa/operations.cc | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/nfa/operations.cc b/src/nfa/operations.cc index 10ed5938..bc9507c0 100644 --- a/src/nfa/operations.cc +++ b/src/nfa/operations.cc @@ -136,14 +136,11 @@ namespace { working_pair = worklist[worklist_size - 1]; worklist.pop_back(); - for (size_t x = 0; x < alph_syms.size(); x++) { - auto symbol_q_ = reverted_nfa.delta[working_pair.second].find(alph_syms[x]); - if (symbol_q_ == reverted_nfa.delta[working_pair.second].end()) { - continue; - } - for (State q: (*symbol_q_).targets.to_vector()) { - if (--matrix[index_fn(x, working_pair.first, q, alph_syms.size(), no_states)] == 0) { - auto symbol_p_ = reverted_nfa.delta[working_pair.first].find(alph_syms[x]); + for (SymbolPost symbol_q_ : reverted_nfa.delta[working_pair.second]) { + Symbol active_sym = symbol_q_.symbol; + for (State q: symbol_q_.targets.to_vector()) { + if (--matrix[index_fn(index_map[active_sym], working_pair.first, q, alph_syms.size(), no_states)] == 0) { + auto symbol_p_ = reverted_nfa.delta[working_pair.first].find(active_sym); if (symbol_p_ == reverted_nfa.delta[working_pair.first].end()) { continue; }