@@ -255,8 +255,18 @@ bool RewriteSystem::addRule(Term lhs, Term rhs) {
255255 rhs.dump (llvm::dbgs ());
256256 llvm::dbgs () << " \n " ;
257257 }
258+
259+ unsigned i = Rules.size ();
258260 Rules.emplace_back (lhs, rhs);
259261
262+ for (unsigned j : indices (Rules)) {
263+ if (i == j)
264+ continue ;
265+
266+ Worklist.emplace_back (i, j);
267+ Worklist.emplace_back (j, i);
268+ }
269+
260270 return true ;
261271}
262272
@@ -301,23 +311,11 @@ bool RewriteSystem::simplify(Term &term) const {
301311}
302312
303313RewriteSystem::CompletionResult
304- RewriteSystem::computeConfluentCompletion (
305- unsigned maxIterations,
306- unsigned maxDepth) {
307- std::deque<std::pair<unsigned , unsigned >> worklist;
308-
309- for (unsigned i : indices (Rules)) {
310- for (unsigned j : indices (Rules)) {
311- if (i == j)
312- continue ;
313-
314- worklist.emplace_back (i, j);
315- }
316- }
317-
318- while (!worklist.empty ()) {
319- auto pair = worklist.front ();
320- worklist.pop_front ();
314+ RewriteSystem::computeConfluentCompletion (unsigned maxIterations,
315+ unsigned maxDepth) {
316+ while (!Worklist.empty ()) {
317+ auto pair = Worklist.front ();
318+ Worklist.pop_front ();
321319
322320 Term first;
323321
@@ -351,14 +349,6 @@ RewriteSystem::computeConfluentCompletion(
351349 if (newRule.getDepth () > maxDepth)
352350 return CompletionResult::MaxDepth;
353351
354- for (unsigned j : indices (Rules)) {
355- if (i == j)
356- continue ;
357-
358- worklist.emplace_back (i, j);
359- worklist.emplace_back (j, i);
360- }
361-
362352 for (unsigned j : indices (Rules)) {
363353 if (i == j)
364354 continue ;
0 commit comments