]> git.ipfire.org Git - thirdparty/vectorscan.git/commitdiff
rose_build_exclusive: clean up use of vertex indices
authorJustin Viiret <justin.viiret@intel.com>
Thu, 3 Aug 2017 05:52:25 +0000 (15:52 +1000)
committerMatthew Barr <matthew.barr@intel.com>
Mon, 21 Aug 2017 01:24:52 +0000 (11:24 +1000)
src/rose/rose_build_exclusive.cpp

index 4c8796f5b43ee8565f45c853c9c8e1a8fda3646c..6a5a710d0482b6817583592eee590f56060266c5 100644 (file)
@@ -219,29 +219,29 @@ bool isExclusive(const NGHolder &h,
     const auto &cr1 = role1.cr;
     if (overlaps(cr1, role2.last_cr)) {
         CharReach cr = cr1 | role1.prefix_cr;
+        flat_set<NFAVertex> states;
         for (const auto &lit : triggers2) {
             auto lit1 = findStartPos(cr, lit);
             if (lit1.empty()) {
                 continue;
             }
-            u32 lower_bound = 0;
-            if (lit1.size() < lit.size()) {
-                lower_bound = ~0U;
-            }
 
-            flat_set<NFAVertex> states;
-            for (const auto &v : vertices_range(h)) {
-                if (h[v].index >= lower_bound || h[v].index < 2) {
-                    states.insert(v);
-                }
+            states.clear();
+
+            if (lit1.size() < lit.size()) {
+                // Only starts.
+                states.insert(h.start);
+                states.insert(h.startDs);
+            } else {
+                // All vertices.
+                insert(&states, vertices(h));
             }
 
             auto activeStates = execute_graph(h, lit1, states);
-            // Check if has only literal states are on
+            // Check if only literal states are on
             for (const auto &s : activeStates) {
-                u32 stateId = h[s].index;
-                if ((stateId > 1 && stateId <= num) ||
-                    contains(tailId, stateId)) {
+                if ((!is_any_start(s, h) && h[s].index <= num) ||
+                    contains(tailId, h[s].index)) {
                     skipList[id2].insert(id1);
                     return false;
                 }