mirror of
https://github.com/VectorCamp/vectorscan.git
synced 2025-09-29 19:24:25 +03:00
determinise: use queue, improve api
- Use a queue rather than always building the full vector of state sets. - Make more use of move, emplace, reserve. - Write directly into dstates argument. - Return bool rather than int.
This commit is contained in:
committed by
Matthew Barr
parent
64db576b9e
commit
31141dd35b
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015-2016, Intel Corporation
|
||||
* Copyright (c) 2015-2017, Intel Corporation
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
@@ -518,7 +518,7 @@ bool doHaig(const NGHolder &g, som_type som,
|
||||
vector<StateSet> nfa_state_map;
|
||||
Auto n(g, som, triggers, unordered_som);
|
||||
try {
|
||||
if (determinise(n, rdfa->states, state_limit, &nfa_state_map)) {
|
||||
if (!determinise(n, rdfa->states, state_limit, &nfa_state_map)) {
|
||||
DEBUG_PRINTF("state limit exceeded\n");
|
||||
return false;
|
||||
}
|
||||
@@ -726,9 +726,8 @@ unique_ptr<raw_som_dfa> attemptToMergeHaig(const vector<const raw_som_dfa *> &df
|
||||
NODE_START,
|
||||
dfas[0]->stream_som_loc_width);
|
||||
|
||||
int rv = determinise(n, rdfa->states, limit, &nfa_state_map);
|
||||
if (rv) {
|
||||
DEBUG_PRINTF("%d:state limit (%u) exceeded\n", rv, limit);
|
||||
if (!determinise(n, rdfa->states, limit, &nfa_state_map)) {
|
||||
DEBUG_PRINTF("state limit (%u) exceeded\n", limit);
|
||||
return nullptr; /* over state limit */
|
||||
}
|
||||
|
||||
|
@@ -433,6 +433,7 @@ public:
|
||||
}
|
||||
return allExternalReports(*rm, test_reports);
|
||||
}
|
||||
|
||||
private:
|
||||
const ReportManager *rm;
|
||||
public:
|
||||
@@ -568,7 +569,7 @@ unique_ptr<raw_dfa> buildMcClellan(const NGHolder &graph,
|
||||
/* Fast path. Automaton_Graph uses a bitfield internally to represent
|
||||
* states and is quicker than Automaton_Big. */
|
||||
Automaton_Graph n(rm, graph, single_trigger, triggers, prunable);
|
||||
if (determinise(n, rdfa->states, state_limit)) {
|
||||
if (!determinise(n, rdfa->states, state_limit)) {
|
||||
DEBUG_PRINTF("state limit exceeded\n");
|
||||
return nullptr; /* over state limit */
|
||||
}
|
||||
@@ -580,7 +581,7 @@ unique_ptr<raw_dfa> buildMcClellan(const NGHolder &graph,
|
||||
} else {
|
||||
/* Slow path. Too many states to use Automaton_Graph. */
|
||||
Automaton_Big n(rm, graph, single_trigger, triggers, prunable);
|
||||
if (determinise(n, rdfa->states, state_limit)) {
|
||||
if (!determinise(n, rdfa->states, state_limit)) {
|
||||
DEBUG_PRINTF("state limit exceeded\n");
|
||||
return nullptr; /* over state limit */
|
||||
}
|
||||
|
Reference in New Issue
Block a user