[clang] [TableGen] Avoid repeated hash lookups (NFC) (PR #126464)
via cfe-commits
cfe-commits at lists.llvm.org
Sun Feb 9 21:28:21 PST 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Kazu Hirata (kazutakahirata)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/126464.diff
1 Files Affected:
- (modified) clang/utils/TableGen/MveEmitter.cpp (+4-11)
``````````diff
diff --git a/clang/utils/TableGen/MveEmitter.cpp b/clang/utils/TableGen/MveEmitter.cpp
index 014b20667e03e4c..7bee2996382c115 100644
--- a/clang/utils/TableGen/MveEmitter.cpp
+++ b/clang/utils/TableGen/MveEmitter.cpp
@@ -1629,17 +1629,10 @@ void EmitterBase::EmitBuiltinCG(raw_ostream &OS) {
for (const auto &OI : kv.second)
key.push_back(OI.ParamValues[i]);
- auto Found = ParamNumberMap.find(key);
- if (Found != ParamNumberMap.end()) {
- // Yes, an existing parameter variable can be reused for this.
- ParamNumbers.push_back(Found->second);
- continue;
- }
-
- // No, we need a new parameter variable.
- int ExistingIndex = ParamNumberMap.size();
- ParamNumberMap[key] = ExistingIndex;
- ParamNumbers.push_back(ExistingIndex);
+ // Obtain a new parameter variable if we don't have one.
+ int ParamNum =
+ ParamNumberMap.try_emplace(key, ParamNumberMap.size()).first->second;
+ ParamNumbers.push_back(ParamNum);
}
// Now we're ready to do the pass 2 code generation, which will emit the
``````````
</details>
https://github.com/llvm/llvm-project/pull/126464
More information about the cfe-commits
mailing list