]> git.ipfire.org Git - thirdparty/vectorscan.git/commitdiff
ng_restructuring: wire start to tops in idx order
authorJustin Viiret <justin.viiret@intel.com>
Tue, 11 Oct 2016 22:49:09 +0000 (09:49 +1100)
committerMatthew Barr <matthew.barr@intel.com>
Fri, 2 Dec 2016 00:25:00 +0000 (11:25 +1100)
src/nfagraph/ng_restructuring.cpp

index 4699033063873260a0fc23d13f03a6e02e698ff9..3b30a6892e1e8cc08f329ae60c65e8c04fdfb74d 100644 (file)
@@ -52,7 +52,11 @@ namespace ue2 {
 static
 void wireStartToTops(NGHolder &g, const flat_set<NFAVertex> &tops,
                      vector<NFAEdge> &tempEdges) {
-    for (NFAVertex v : tops) {
+    // Construct edges in vertex index order, for determinism.
+    vector<NFAVertex> ordered_tops(begin(tops), end(tops));
+    sort(begin(ordered_tops), end(ordered_tops), make_index_ordering(g));
+
+    for (NFAVertex v : ordered_tops) {
         assert(!isLeafNode(v, g));
 
         const NFAEdge &e = add_edge(g.start, v, g).first;