[llvm] [Analysis] Avoid repeated hash lookups (NFC) (PR #112297)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 14 20:28:16 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-analysis
Author: Kazu Hirata (kazutakahirata)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/112297.diff
1 Files Affected:
- (modified) llvm/include/llvm/Analysis/RegionInfoImpl.h (+4-7)
``````````diff
diff --git a/llvm/include/llvm/Analysis/RegionInfoImpl.h b/llvm/include/llvm/Analysis/RegionInfoImpl.h
index ebfb060ded3dd4..db3a9027549cef 100644
--- a/llvm/include/llvm/Analysis/RegionInfoImpl.h
+++ b/llvm/include/llvm/Analysis/RegionInfoImpl.h
@@ -338,14 +338,11 @@ template <class Tr>
typename Tr::RegionNodeT *RegionBase<Tr>::getBBNode(BlockT *BB) const {
assert(contains(BB) && "Can get BB node out of this region!");
- typename BBNodeMapT::const_iterator at = BBNodeMap.find(BB);
-
- if (at == BBNodeMap.end()) {
+ auto [at, Inserted] = BBNodeMap.try_emplace(BB);
+ if (Inserted) {
auto Deconst = const_cast<RegionBase<Tr> *>(this);
- typename BBNodeMapT::value_type V = {
- BB,
- std::make_unique<RegionNodeT>(static_cast<RegionT *>(Deconst), BB)};
- at = BBNodeMap.insert(std::move(V)).first;
+ at->second =
+ std::make_unique<RegionNodeT>(static_cast<RegionT *>(Deconst), BB);
}
return at->second.get();
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/112297
More information about the llvm-commits
mailing list