mirror of
https://github.com/VectorCamp/vectorscan.git
synced 2025-07-14 06:24:43 +03:00
smallwrite: bfs ordering, refine daddy selection
This commit is contained in:
parent
3b3f6b739c
commit
10f52346ca
@ -841,9 +841,17 @@ void find_better_daddy(dfa_info &info, dstate_id_t curr_id, bool using8bit,
|
|||||||
|
|
||||||
flat_set<dstate_id_t> hinted;
|
flat_set<dstate_id_t> hinted;
|
||||||
if (trust_daddy_states) {
|
if (trust_daddy_states) {
|
||||||
hinted.insert(currState.daddy);
|
// Use the daddy already set for this state so long as it isn't already
|
||||||
addIfEarlier(hinted, info.raw.start_floating, curr_id);
|
// a Sherman state.
|
||||||
addIfEarlier(hinted, info.raw.start_anchored, curr_id);
|
if (!info.is_sherman(currState.daddy)) {
|
||||||
|
hinted.insert(currState.daddy);
|
||||||
|
} else {
|
||||||
|
// Fall back to granddaddy, which has already been processed (due
|
||||||
|
// to BFS ordering) and cannot be a Sherman state.
|
||||||
|
dstate_id_t granddaddy = info.states[currState.daddy].daddy;
|
||||||
|
assert(!info.is_sherman(granddaddy));
|
||||||
|
hinted.insert(granddaddy);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
hinted = find_daddy_candidates(info, curr_id);
|
hinted = find_daddy_candidates(info, curr_id);
|
||||||
}
|
}
|
||||||
|
@ -452,6 +452,13 @@ void buildAutomaton(LitTrie &trie,
|
|||||||
ACVisitor ac_vis(trie, failure_map, ordering);
|
ACVisitor ac_vis(trie, failure_map, ordering);
|
||||||
boost::breadth_first_search(trie, trie.root, visitor(ac_vis));
|
boost::breadth_first_search(trie, trie.root, visitor(ac_vis));
|
||||||
|
|
||||||
|
// Renumber with BFS ordering, which is assumed by other DFA construction
|
||||||
|
// code (i.e. Sherman state computation).
|
||||||
|
size_t idx = 0;
|
||||||
|
for (auto v : ordering) {
|
||||||
|
trie[v].index = idx++;
|
||||||
|
}
|
||||||
|
|
||||||
// Compute missing edges from failure map.
|
// Compute missing edges from failure map.
|
||||||
for (auto v : ordering) {
|
for (auto v : ordering) {
|
||||||
DEBUG_PRINTF("vertex %zu\n", trie[v].index);
|
DEBUG_PRINTF("vertex %zu\n", trie[v].index);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user