@@ -255,8 +255,18 @@ bool RewriteSystem::addRule(Term lhs, Term rhs) {
255
255
rhs.dump (llvm::dbgs ());
256
256
llvm::dbgs () << " \n " ;
257
257
}
258
+
259
+ unsigned i = Rules.size ();
258
260
Rules.emplace_back (lhs, rhs);
259
261
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
+
260
270
return true ;
261
271
}
262
272
@@ -301,23 +311,11 @@ bool RewriteSystem::simplify(Term &term) const {
301
311
}
302
312
303
313
RewriteSystem::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 ();
321
319
322
320
Term first;
323
321
@@ -351,14 +349,6 @@ RewriteSystem::computeConfluentCompletion(
351
349
if (newRule.getDepth () > maxDepth)
352
350
return CompletionResult::MaxDepth;
353
351
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
-
362
352
for (unsigned j : indices (Rules)) {
363
353
if (i == j)
364
354
continue ;
0 commit comments