mirror of
https://github.com/VectorCamp/vectorscan.git
synced 2025-06-28 16:41:01 +03:00
smallwrite: don't recompile the dfa if prune fails
This commit is contained in:
parent
ed3ef5b997
commit
ff82ea6d6e
@ -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);
|
DEBUG_PRINTF("pruning to at most %u\n", max_offset);
|
||||||
vector<u32> bob_dist;
|
vector<u32> bob_dist;
|
||||||
u32 max_min_dist_bob = calc_min_dist_from_bob(raw, &bob_dist);
|
u32 max_min_dist_bob = calc_min_dist_from_bob(raw, &bob_dist);
|
||||||
|
|
||||||
if (max_min_dist_bob <= max_offset) {
|
if (max_min_dist_bob <= max_offset) {
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
vector<vector<dstate_id_t> > in_edges;
|
vector<vector<dstate_id_t> > in_edges;
|
||||||
@ -282,6 +282,8 @@ void prune_overlong(raw_dfa &raw, u32 max_offset) {
|
|||||||
/* update specials */
|
/* update specials */
|
||||||
raw.start_floating = new_ids[raw.start_floating];
|
raw.start_floating = new_ids[raw.start_floating];
|
||||||
raw.start_anchored = new_ids[raw.start_anchored];
|
raw.start_anchored = new_ids[raw.start_anchored];
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
set<ReportID> all_reports(const raw_dfa &rdfa) {
|
set<ReportID> all_reports(const raw_dfa &rdfa) {
|
||||||
|
@ -37,7 +37,13 @@
|
|||||||
namespace ue2 {
|
namespace ue2 {
|
||||||
|
|
||||||
u32 remove_leading_dots(raw_dfa &raw);
|
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);
|
std::set<ReportID> all_reports(const raw_dfa &rdfa);
|
||||||
bool has_eod_accepts(const raw_dfa &rdfa);
|
bool has_eod_accepts(const raw_dfa &rdfa);
|
||||||
bool has_non_eod_accepts(const raw_dfa &rdfa);
|
bool has_non_eod_accepts(const raw_dfa &rdfa);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2015, Intel Corporation
|
* Copyright (c) 2015-2016, Intel Corporation
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are met:
|
* modification, are permitted provided that the following conditions are met:
|
||||||
@ -317,21 +317,23 @@ aligned_unique_ptr<NFA> prepEngine(raw_dfa &rdfa, u32 roseQuality,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (is_slow(rdfa, accel_states, roseQuality)) {
|
if (is_slow(rdfa, accel_states, roseQuality)) {
|
||||||
|
DEBUG_PRINTF("is slow\n");
|
||||||
*small_region = cc.grey.smallWriteLargestBufferBad;
|
*small_region = cc.grey.smallWriteLargestBufferBad;
|
||||||
if (*small_region <= *start_offset) {
|
if (*small_region <= *start_offset) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
prune_overlong(rdfa, *small_region - *start_offset);
|
if (prune_overlong(rdfa, *small_region - *start_offset)) {
|
||||||
if (rdfa.start_anchored == DEAD_STATE) {
|
if (rdfa.start_anchored == DEAD_STATE) {
|
||||||
DEBUG_PRINTF("all patterns pruned out\n");
|
DEBUG_PRINTF("all patterns pruned out\n");
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
nfa = mcclellanCompile(rdfa, cc, &accel_states);
|
nfa = mcclellanCompile(rdfa, cc, &accel_states);
|
||||||
if (!nfa) {
|
if (!nfa) {
|
||||||
DEBUG_PRINTF("mcclellan compile failed for smallwrite NFA\n");
|
DEBUG_PRINTF("mcclellan compile failed for smallwrite NFA\n");
|
||||||
assert(0); /* we were able to build orig dfa but not the trimmed? */
|
assert(0); /* able to build orig dfa but not the trimmed? */
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
*small_region = cc.grey.smallWriteLargestBuffer;
|
*small_region = cc.grey.smallWriteLargestBuffer;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user