ng_mcclellan: reject determinise if NFA is too big

This commit is contained in:
Justin Viiret 2017-06-26 16:15:23 +10:00 committed by Matthew Barr
parent e8f09aa8c6
commit 2fba9bd16c

View File

@ -558,11 +558,16 @@ unique_ptr<raw_dfa> buildMcClellan(const NGHolder &graph,
= (graph.kind == NFA_OUTFIX || finalChance) ? FINAL_DFA_STATE_LIMIT
: DFA_STATE_LIMIT;
unique_ptr<raw_dfa> rdfa = ue2::make_unique<raw_dfa>(graph.kind);
const u32 numStates = num_vertices(graph);
DEBUG_PRINTF("determinising nfa with %u vertices\n", numStates);
if (numStates > FINAL_DFA_STATE_LIMIT) {
DEBUG_PRINTF("rejecting nfa as too many vertices\n");
return nullptr;
}
auto rdfa = ue2::make_unique<raw_dfa>(graph.kind);
if (numStates <= NFA_STATE_LIMIT) {
/* Fast path. Automaton_Graph uses a bitfield internally to represent
* states and is quicker than Automaton_Big. */