[clang] 5b7b52f - [TableGen] Avoid repeated hash lookups (NFC) (#109372)

via cfe-commits cfe-commits at lists.llvm.org
Fri Sep 20 09:03:28 PDT 2024


Author: Kazu Hirata
Date: 2024-09-20T09:03:25-07:00
New Revision: 5b7b52f9e9ac783d645f6cfc53a6822be2c40067

URL: https://github.com/llvm/llvm-project/commit/5b7b52f9e9ac783d645f6cfc53a6822be2c40067
DIFF: https://github.com/llvm/llvm-project/commit/5b7b52f9e9ac783d645f6cfc53a6822be2c40067.diff

LOG: [TableGen] Avoid repeated hash lookups (NFC) (#109372)

Added: 
    

Modified: 
    clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp

Removed: 
    


################################################################################
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());


        


More information about the cfe-commits mailing list