Skip to content

Commit 60c5c4c

Browse files
authored
[MLIR] Don't check for key before inserting in map in GreedyPatternRewriteDriver worklist (NFC) (#88148)
This is a common anti-pattern (any volunteer for a clang-tidy check?). This does not show real word significant impact though.
1 parent ca70568 commit 60c5c4c

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,9 +243,8 @@ bool Worklist::empty() const {
243243
void Worklist::push(Operation *op) {
244244
assert(op && "cannot push nullptr to worklist");
245245
// Check to see if the worklist already contains this op.
246-
if (map.count(op))
246+
if (!map.insert({op, list.size()}).second)
247247
return;
248-
map[op] = list.size();
249248
list.push_back(op);
250249
}
251250

0 commit comments

Comments
 (0)