Skip to content

Commit

Permalink
[Transform] Avoid repeated hash lookups (NFC)
Browse files Browse the repository at this point in the history
  • Loading branch information
kazutakahirata committed Oct 9, 2024
1 parent 64a22b3 commit 30aad2c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions mlir/lib/Dialect/Transform/Transforms/CheckUses.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ template <typename FnTy>
const llvm::SmallPtrSet<Block *, 4> &
getReachableImpl(Block *block, FnTy getNextNodes,
DenseMap<Block *, llvm::SmallPtrSet<Block *, 4>> &cache) {
auto it = cache.find(block);
if (it != cache.end())
auto [it, inserted] = cache.try_emplace(block);
if (!inserted)
return it->getSecond();

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

0 comments on commit 30aad2c

Please sign in to comment.