]> git.ipfire.org Git - thirdparty/vectorscan.git/commitdiff
ng_limex: add edges in deterministic ordering
authorJustin Viiret <justin.viiret@intel.com>
Tue, 11 Oct 2016 22:53:12 +0000 (09:53 +1100)
committerMatthew Barr <matthew.barr@intel.com>
Fri, 2 Dec 2016 00:26:33 +0000 (11:26 +1100)
src/nfagraph/ng_limex.cpp

index 5f78246087aefa3b2d8dbcfdfcf52a9bc6c499a2..5e5a18d9dbdcf5011391a6e5fbe92096cb4bff0e 100644 (file)
@@ -177,7 +177,12 @@ NFAVertex makeTopStartVertex(NGHolder &g, const flat_set<u32> &tops,
     NFAVertex u = add_vertex(g[g.start], g);
     CharReach top_cr = calcTopVertexReach(tops, top_reach);
     g[u].char_reach = top_cr;
-    for (auto v : succs) {
+
+    // Add edges in vertex index order, for determinism.
+    vector<NFAVertex> ordered_succs(begin(succs), end(succs));
+    sort(begin(ordered_succs), end(ordered_succs), make_index_ordering(g));
+
+    for (auto v : ordered_succs) {
         if (v == g.accept || v == g.acceptEod) {
             reporter = true;
         }