https://github.com/kazutakahirata created 
https://github.com/llvm/llvm-project/pull/109372

None

>From b8009302e897f8759c18e74012ea8b4901a82481 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <k...@google.com>
Date: Thu, 19 Sep 2024 09:21:50 -0700
Subject: [PATCH] [TableGen] Avoid repeated hash lookups (NFC)

---
 clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp 
b/clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
index 4ce8655f6883e6..25c7bf0306a891 100644
--- a/clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
+++ b/clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
@@ -896,9 +896,8 @@ static void OCL2Qual(Sema &S, const OpenCLTypeStruct &Ty,
     if (ImageTypesMap.contains(T->getValueAsString("Name")))
       continue;
     // Check we have not seen this Type
-    if (TypesSeen.contains(T->getValueAsString("Name")))
+    if (!TypesSeen.try_emplace(T->getValueAsString("Name"), true).second)
       continue;
-    TypesSeen.insert(std::make_pair(T->getValueAsString("Name"), true));
 
     // Check the Type does not have an "abstract" QualType
     auto QT = T->getValueAsDef("QTExpr");
@@ -1081,9 +1080,8 @@ void OpenCLBuiltinFileEmitterBase::expandTypesInSignature(
         // the full type name to the extension.
         StringRef Ext =
             Type->getValueAsDef("Extension")->getValueAsString("ExtName");
-        if (!Ext.empty() && !TypeExtMap.contains(FullType)) {
-          TypeExtMap.insert({FullType, Ext});
-        }
+        if (!Ext.empty())
+          TypeExtMap.try_emplace(FullType, Ext);
       }
     }
     NumSignatures = std::max<unsigned>(NumSignatures, ExpandedArg.size());

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to