ng_execute: update interface to use flat_set

This changes all the execute_graph() interfaces so that instead of
mutating a std::set of vertices, they accept an initial flat_set of
states and return a resultant flat_set of states after execution.

(Note that internally execute_graph() still uses bitsets)

This is both faster and more flexible.
This commit is contained in:
Justin Viiret
2015-11-13 14:36:28 +11:00
committed by Matthew Barr
parent fd19168025
commit abbd548899
5 changed files with 79 additions and 69 deletions

View File

@@ -136,7 +136,7 @@ bool firstMatchIsFirst(const NGHolder &p) {
return false;
}
set<NFAVertex> states;
ue2::flat_set<NFAVertex> states;
/* turn on all states (except starts - avoid suffix matches) */
/* If we were doing (1) we would also except states leading to accepts -
avoid prefix matches */
@@ -149,7 +149,7 @@ bool firstMatchIsFirst(const NGHolder &p) {
}
/* run the prefix the main graph */
execute_graph(p, p, &states);
states = execute_graph(p, p, states);
for (auto v : states) {
/* need to check if this vertex may represent an infix match - ie
@@ -313,7 +313,7 @@ bool sentClearsTail(const NGHolder &g,
*/
u32 first_bad_region = ~0U;
set<NFAVertex> states;
ue2::flat_set<NFAVertex> states;
/* turn on all states */
DEBUG_PRINTF("region %u is cutover\n", last_head_region);
for (auto v : vertices_range(g)) {
@@ -327,7 +327,7 @@ bool sentClearsTail(const NGHolder &g,
}
/* run the prefix the main graph */
execute_graph(g, sent, &states);
states = execute_graph(g, sent, states);
/* .. and check if we are left with anything in the tail region */
for (auto v : states) {