[clang] ba9810e - [TableGen] Avoid repeated hash lookups (NFC) (#126464)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Feb 10 07:49:47 PST 2025
Author: Kazu Hirata
Date: 2025-02-10T07:49:42-08:00
New Revision: ba9810e803744974157e85a80854e163818db608
URL: https://github.com/llvm/llvm-project/commit/ba9810e803744974157e85a80854e163818db608
DIFF: https://github.com/llvm/llvm-project/commit/ba9810e803744974157e85a80854e163818db608.diff
LOG: [TableGen] Avoid repeated hash lookups (NFC) (#126464)
Added:
Modified:
clang/utils/TableGen/MveEmitter.cpp
Removed:
################################################################################
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
More information about the cfe-commits
mailing list