]> git.ipfire.org Git - thirdparty/vectorscan.git/commitdiff
ng_violet: iterate in edge order
authorJustin Viiret <justin.viiret@intel.com>
Thu, 21 Jul 2016 02:57:12 +0000 (12:57 +1000)
committerMatthew Barr <matthew.barr@intel.com>
Wed, 10 Aug 2016 05:06:43 +0000 (15:06 +1000)
src/nfagraph/ng_violet.cpp

index fe917c77fa65f1cfba00d55a0b09e18020aea5cf..3c79dbc38af862b2896d526fd5596a270b2754ac 100644 (file)
@@ -1622,7 +1622,8 @@ void removeRedundantLiteralsFromInfix(const NGHolder &h, RoseInGraph &ig,
 static
 void removeRedundantLiteralsFromInfixes(RoseInGraph &g,
                                         const CompileContext &cc) {
-    map<NGHolder *, vector<RoseInEdge> > infixes;
+    vector<NGHolder *> seen_order;
+    map<NGHolder *, vector<RoseInEdge>> infixes;
 
     for (const RoseInEdge &e : edges_range(g)) {
         RoseInVertex s = source(e, g);
@@ -1637,11 +1638,16 @@ void removeRedundantLiteralsFromInfixes(RoseInGraph &g,
         }
 
         assert(!g[t].delay);
-        infixes[&*g[e].graph].push_back(e);
+
+        NGHolder *h = g[e].graph.get();
+        if (!contains(infixes, h)) {
+            seen_order.push_back(h);
+        }
+        infixes[h].push_back(e);
     }
 
-    for (const auto &info : infixes) {
-        removeRedundantLiteralsFromInfix(*info.first, g, info.second, cc);
+    for (NGHolder *h : seen_order) {
+        removeRedundantLiteralsFromInfix(*h, g, infixes[h], cc);
     }
 }