Skip to content

Commit 7d9f993

Browse files
[Transform] Avoid repeated hash lookups (NFC) (#111620)
1 parent 6f8e855 commit 7d9f993

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

mlir/lib/Dialect/Transform/Transforms/CheckUses.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@ template <typename FnTy>
3939
const llvm::SmallPtrSet<Block *, 4> &
4040
getReachableImpl(Block *block, FnTy getNextNodes,
4141
DenseMap<Block *, llvm::SmallPtrSet<Block *, 4>> &cache) {
42-
auto it = cache.find(block);
43-
if (it != cache.end())
42+
auto [it, inserted] = cache.try_emplace(block);
43+
if (!inserted)
4444
return it->getSecond();
4545

46-
llvm::SmallPtrSet<Block *, 4> &reachable = cache[block];
46+
llvm::SmallPtrSet<Block *, 4> &reachable = it->second;
4747
SmallVector<Block *> worklist;
4848
worklist.push_back(block);
4949
while (!worklist.empty()) {

0 commit comments

Comments
 (0)