Skip to content

Commit 9825d1f

Browse files
[PDL] Avoid repeated hash lookups (NFC) (#108927)
1 parent 65a5b18 commit 9825d1f

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

mlir/lib/Dialect/PDL/IR/PDL.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,10 @@ static void visit(Operation *op, DenseSet<Operation *> &visited) {
6565
if (!isa<PatternOp>(op->getParentOp()) || isa<RewriteOp>(op))
6666
return;
6767

68-
// Ignore if already visited.
69-
if (visited.contains(op))
68+
// Ignore if already visited. Otherwise, mark as visited.
69+
if (!visited.insert(op).second)
7070
return;
7171

72-
// Mark as visited.
73-
visited.insert(op);
74-
7572
// Traverse the operands / parent.
7673
TypeSwitch<Operation *>(op)
7774
.Case<OperationOp>([&visited](auto operation) {

0 commit comments

Comments
 (0)