From 34ed4a6991eb913f90d0353626df4ae3590f16c5 Mon Sep 17 00:00:00 2001 From: Alex Coyte Date: Tue, 8 Aug 2017 10:13:46 +1000 Subject: [PATCH] violet: maintain a reference to all the known implementable graphs --- src/nfagraph/ng_violet.cpp | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/nfagraph/ng_violet.cpp b/src/nfagraph/ng_violet.cpp index b5e662cc..0a3a97a0 100644 --- a/src/nfagraph/ng_violet.cpp +++ b/src/nfagraph/ng_violet.cpp @@ -2898,22 +2898,22 @@ bool ensureImplementable(RoseBuild &rose, RoseInGraph &vg, bool allow_changes, bool changed = false; bool need_to_recalc = false; u32 added_count = 0; - unordered_set good; /* known to be implementable */ + unordered_set> good; /* known to be implementable */ do { changed = false; DEBUG_PRINTF("added %u\n", added_count); map > edges_by_graph; - vector graphs; + vector> graphs; for (const RoseInEdge &ve : edges_range(vg)) { if (vg[ve].graph && !vg[ve].dfa) { - NGHolder *h = vg[ve].graph.get(); - if (!contains(edges_by_graph, h)) { + auto &h = vg[ve].graph; + if (!contains(edges_by_graph, h.get())) { graphs.push_back(h); } - edges_by_graph[h].push_back(ve); + edges_by_graph[h.get()].push_back(ve); } } - for (NGHolder *h : graphs) { + for (auto &h : graphs) { if (contains(good, h)) { continue; } @@ -2924,9 +2924,8 @@ bool ensureImplementable(RoseBuild &rose, RoseInGraph &vg, bool allow_changes, } if (tryForEarlyDfa(*h, cc) - && doEarlyDfa(rose, vg, *h, edges_by_graph[h], final_chance, rm, - cc)) { - good.insert(h); + && doEarlyDfa(rose, vg, *h, edges_by_graph[h.get()], + final_chance, rm, cc)) { continue; } @@ -2935,7 +2934,7 @@ bool ensureImplementable(RoseBuild &rose, RoseInGraph &vg, bool allow_changes, return false; } - if (splitForImplementability(vg, *h, edges_by_graph[h], cc)) { + if (splitForImplementability(vg, *h, edges_by_graph[h.get()], cc)) { added_count++; if (added_count > MAX_IMPLEMENTABLE_SPLITS) { DEBUG_PRINTF("added_count hit limit\n");