]> git.ipfire.org Git - thirdparty/vectorscan.git/commitdiff
smallwrite: minimize DFAs if they have been pruned
authorJustin Viiret <justin.viiret@intel.com>
Tue, 11 Oct 2016 04:36:16 +0000 (15:36 +1100)
committerMatthew Barr <matthew.barr@intel.com>
Fri, 2 Dec 2016 00:28:12 +0000 (11:28 +1100)
src/smallwrite/smallwrite_build.cpp

index 65361c6f50cf5685eba0c87bc5555f2007c494a4..d395a7af62638063b0a9fb724374a36a19604222 100644 (file)
@@ -30,6 +30,7 @@
 
 #include "grey.h"
 #include "ue2common.h"
+#include "nfa/dfa_min.h"
 #include "nfa/mcclellancompile.h"
 #include "nfa/mcclellancompile_util.h"
 #include "nfa/nfa_internal.h"
@@ -208,7 +209,9 @@ void SmallWriteBuildImpl::add(const NGWrapper &w) {
         return;
     }
 
-    prune_overlong(*r, cc.grey.smallWriteLargestBuffer);
+    if (prune_overlong(*r, cc.grey.smallWriteLargestBuffer)) {
+        minimize_hopcroft(*r, cc.grey);
+    }
 
     if (rdfa) {
         // do a merge of the new dfa with the existing dfa
@@ -418,6 +421,7 @@ aligned_unique_ptr<NFA> prepEngine(raw_dfa &rdfa, u32 roseQuality,
             return nullptr;
         }
         if (prune_overlong(rdfa, *small_region - *start_offset)) {
+            minimize_hopcroft(rdfa, cc.grey);
             if (rdfa.start_anchored == DEAD_STATE) {
                 DEBUG_PRINTF("all patterns pruned out\n");
                 return nullptr;