]> git.ipfire.org Git - thirdparty/vectorscan.git/commitdiff
smwr: more aggressive pruning of overlong paths in NFA
authorAlex Coyte <a.coyte@intel.com>
Mon, 1 May 2017 03:31:09 +0000 (13:31 +1000)
committerMatthew Barr <matthew.barr@intel.com>
Tue, 30 May 2017 03:59:00 +0000 (13:59 +1000)
src/smallwrite/smallwrite_build.cpp

index ba2f244dfbdfd3dfc0629e9eae368c19ce777fab..4390020783e745d4fe7b3149ae111419b8ce9a1d 100644 (file)
@@ -198,15 +198,16 @@ static
 bool pruneOverlong(NGHolder &g, const depth &max_depth,
                    const ReportManager &rm) {
     bool modified = false;
-    auto depths = calcDepths(g);
+    auto depths = calcBidiDepths(g);
 
     for (auto v : vertices_range(g)) {
         if (is_special(v, g)) {
             continue;
         }
         const auto &d = depths.at(g[v].index);
-        depth min_depth = min(d.fromStart.min, d.fromStartDotStar.min);
-        if (min_depth > max_depth) {
+        depth min_match_offset = min(d.fromStart.min, d.fromStartDotStar.min)
+                               + min(d.toAccept.min, d.toAcceptEod.min);
+        if (min_match_offset > max_depth) {
             clear_vertex(v, g);
             modified = true;
             continue;