From 68c8845d15c652599a154c61d835dba810ef3ab0 Mon Sep 17 00:00:00 2001 From: Alex Coyte Date: Tue, 18 Jul 2017 12:49:32 +1000 Subject: [PATCH] Do equivalency removal before violet's implementablity check. This is helpful as removing/restoring literals may introduce redundancy in the graphs. Also improve the implementation by caching known good holders. --- src/nfagraph/ng_violet.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/nfagraph/ng_violet.cpp b/src/nfagraph/ng_violet.cpp index 6742fec9..e19a6211 100644 --- a/src/nfagraph/ng_violet.cpp +++ b/src/nfagraph/ng_violet.cpp @@ -1759,7 +1759,6 @@ void removeRedundantLiteralsFromInfixes(RoseInGraph &g, } } - static void removeRedundantLiterals(RoseInGraph &g, const CompileContext &cc) { removeRedundantLiteralsFromPrefixes(g, cc); @@ -2886,6 +2885,7 @@ 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 */ do { changed = false; DEBUG_PRINTF("added %u\n", added_count); @@ -2901,13 +2901,19 @@ bool ensureImplementable(RoseBuild &rose, RoseInGraph &vg, bool allow_changes, } } for (NGHolder *h : graphs) { + if (contains(good, h)) { + continue; + } + reduceGraphEquivalences(*h, cc); if (isImplementableNFA(*h, &rm, cc)) { + good.insert(h); continue; } if (tryForEarlyDfa(*h, cc) && doEarlyDfa(rose, vg, *h, edges_by_graph[h], final_chance, rm, cc)) { + good.insert(h); continue; } @@ -2923,6 +2929,7 @@ bool ensureImplementable(RoseBuild &rose, RoseInGraph &vg, bool allow_changes, return false; } changed = true; + good.insert(h); continue; }