[clang] 56f061f - [TableGen] Avoid repeated hash lookups (NFC) (#108736)

via cfe-commits cfe-commits at lists.llvm.org
Sun Sep 15 01:20:40 PDT 2024


Author: Kazu Hirata
Date: 2024-09-15T01:20:37-07:00
New Revision: 56f061f71b66a01a7f89069873f9c6dcda82b044

URL: https://github.com/llvm/llvm-project/commit/56f061f71b66a01a7f89069873f9c6dcda82b044
DIFF: https://github.com/llvm/llvm-project/commit/56f061f71b66a01a7f89069873f9c6dcda82b044.diff

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

Added: 
    

Modified: 
    clang/utils/TableGen/ClangAttrEmitter.cpp

Removed: 
    


################################################################################
diff  --git a/clang/utils/TableGen/ClangAttrEmitter.cpp b/clang/utils/TableGen/ClangAttrEmitter.cpp
index 9b2249ac90bc5c..637484149d4438 100644
--- a/clang/utils/TableGen/ClangAttrEmitter.cpp
+++ b/clang/utils/TableGen/ClangAttrEmitter.cpp
@@ -203,12 +203,11 @@ static ParsedAttrMap getParsedAttrList(const RecordKeeper &Records,
 
         // If this attribute has already been handled, it does not need to be
         // handled again.
-        if (Seen.find(AN) != Seen.end()) {
+        if (!Seen.insert(AN).second) {
           if (Dupes)
             Dupes->push_back(std::make_pair(AN, Attr));
           continue;
         }
-        Seen.insert(AN);
       } else
         AN = NormalizeAttrName(Attr->getName()).str();
 
@@ -1824,10 +1823,9 @@ CreateSemanticSpellings(const std::vector<FlattenedSpelling> &Spellings,
     // reserved namespace, we may have inadvertently created duplicate
     // enumerant names. These duplicates are not considered part of the
     // semantic spelling, and can be elided.
-    if (Uniques.find(EnumName) != Uniques.end())
+    if (!Uniques.insert(EnumName).second)
       continue;
 
-    Uniques.insert(EnumName);
     if (I != Spellings.begin())
       Ret += ",\n";
     // Duplicate spellings are not considered part of the semantic spelling


        


More information about the cfe-commits mailing list