https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/126464
None >From 471b2f287c7b3b1ade9dbe5b1d9cb10affa0a6e6 Mon Sep 17 00:00:00 2001 From: Kazu Hirata <k...@google.com> Date: Sun, 9 Feb 2025 16:20:17 -0800 Subject: [PATCH] [TableGen] Avoid repeated hash lookups (NFC) --- clang/utils/TableGen/MveEmitter.cpp | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) 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 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits