smallwrite: don't recompile the dfa if prune fails

This commit is contained in:
Alex Coyte
2016-04-05 11:07:26 +10:00
committed by Matthew Barr
parent ed3ef5b997
commit ff82ea6d6e
3 changed files with 24 additions and 14 deletions

View File

@@ -228,13 +228,13 @@ void calc_min_dist_to_accept(const raw_dfa &raw,
}
}
void prune_overlong(raw_dfa &raw, u32 max_offset) {
bool prune_overlong(raw_dfa &raw, u32 max_offset) {
DEBUG_PRINTF("pruning to at most %u\n", max_offset);
vector<u32> bob_dist;
u32 max_min_dist_bob = calc_min_dist_from_bob(raw, &bob_dist);
if (max_min_dist_bob <= max_offset) {
return;
return false;
}
vector<vector<dstate_id_t> > in_edges;
@@ -282,6 +282,8 @@ void prune_overlong(raw_dfa &raw, u32 max_offset) {
/* update specials */
raw.start_floating = new_ids[raw.start_floating];
raw.start_anchored = new_ids[raw.start_anchored];
return true;
}
set<ReportID> all_reports(const raw_dfa &rdfa) {

View File

@@ -37,7 +37,13 @@
namespace ue2 {
u32 remove_leading_dots(raw_dfa &raw);
void prune_overlong(raw_dfa &raw, u32 max_offset);
/**
* Prunes any states which cannot be reached within max_offset from start of
* stream. Returns false if no changes are made to the rdfa
*/
bool prune_overlong(raw_dfa &raw, u32 max_offset);
std::set<ReportID> all_reports(const raw_dfa &rdfa);
bool has_eod_accepts(const raw_dfa &rdfa);
bool has_non_eod_accepts(const raw_dfa &rdfa);