]> git.ipfire.org Git - thirdparty/vectorscan.git/commitdiff
ng_region: simplify checkAndAddExitCandidate
authorJustin Viiret <justin.viiret@intel.com>
Tue, 14 Mar 2017 22:37:21 +0000 (09:37 +1100)
committerMatthew Barr <matthew.barr@intel.com>
Wed, 26 Apr 2017 05:18:13 +0000 (15:18 +1000)
src/nfagraph/ng_region.cpp

index 8adecfcf42be23cefda334501d40700ece61e03f..39a8a504b77b1e770d5f345f8087cc5cc43c6127 100644 (file)
@@ -87,22 +87,19 @@ static
 void checkAndAddExitCandidate(const AcyclicGraph &g,
                               const ue2::unordered_set<NFAVertex> &r,
                               NFAVertex v, vector<exit_info> &exits) {
-    // set when we find our first candidate.
-    decltype(exit_info::open) *open = nullptr;
+    exit_info v_exit(v);
+    auto &open = v_exit.open;
 
     /* find the set of vertices reachable from v which are not in r */
     for (auto w : adjacent_vertices_range(v, g)) {
-        if (!contains(r, NFAVertex(w))) {
-            if (!open) {
-                exits.emplace_back(NFAVertex(v));
-                open = &exits.back().open;
-            }
-            open->insert(NFAVertex(w));
+        if (!contains(r, w)) {
+            open.insert(w);
         }
     }
 
-    if (open) {
+    if (!open.empty()) {
         DEBUG_PRINTF("exit %zu\n", g[v].index);
+        exits.push_back(move(v_exit));
     }
 }