[Mlir-commits] [mlir] [mlir] Avoid repeated hash lookups (NFC) (PR #107519)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Thu Sep 5 21:37:47 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-mlir-core
Author: Kazu Hirata (kazutakahirata)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/107519.diff
1 Files Affected:
- (modified) mlir/lib/IR/AttrTypeSubElements.cpp (+3-3)
``````````diff
diff --git a/mlir/lib/IR/AttrTypeSubElements.cpp b/mlir/lib/IR/AttrTypeSubElements.cpp
index 783236ed3a9df6..863e1aa95f2fb7 100644
--- a/mlir/lib/IR/AttrTypeSubElements.cpp
+++ b/mlir/lib/IR/AttrTypeSubElements.cpp
@@ -27,10 +27,10 @@ WalkResult AttrTypeWalker::walkImpl(T element, WalkFns &walkFns,
WalkOrder order) {
// Check if we've already walk this element before.
auto key = std::make_pair(element.getAsOpaquePointer(), (int)order);
- auto it = visitedAttrTypes.find(key);
- if (it != visitedAttrTypes.end())
+ auto [it, inserted] =
+ visitedAttrTypes.try_emplace(key, WalkResult::advance());
+ if (!inserted)
return it->second;
- visitedAttrTypes.try_emplace(key, WalkResult::advance());
// If we are walking in post order, walk the sub elements first.
if (order == WalkOrder::PostOrder) {
``````````
</details>
https://github.com/llvm/llvm-project/pull/107519
More information about the Mlir-commits
mailing list