[clang] ccc066e - [TableGen] Avoid repeated map lookups (NFC) (#124448)

via cfe-commits cfe-commits at lists.llvm.org
Sun Jan 26 11:50:15 PST 2025


Author: Kazu Hirata
Date: 2025-01-26T11:50:10-08:00
New Revision: ccc066e8d5a742f79b41a0f90ef309d5b9e92c2a

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

LOG: [TableGen] Avoid repeated map lookups (NFC) (#124448)

This patch avoids repeated map lookups and constructions of temporary
std::string instances by switching to DenseSet.

Added: 
    

Modified: 
    clang/utils/TableGen/MveEmitter.cpp

Removed: 
    


################################################################################
diff  --git a/clang/utils/TableGen/MveEmitter.cpp b/clang/utils/TableGen/MveEmitter.cpp
index 8ebd0bb800feff..58a4d3c22ac366 100644
--- a/clang/utils/TableGen/MveEmitter.cpp
+++ b/clang/utils/TableGen/MveEmitter.cpp
@@ -1955,18 +1955,17 @@ void MveEmitter::EmitBuiltinDef(raw_ostream &OS) {
        << ", \"\", \"n\")\n";
   }
 
-  std::set<std::string> ShortNamesSeen;
+  DenseSet<StringRef> ShortNamesSeen;
 
   for (const auto &kv : ACLEIntrinsics) {
     const ACLEIntrinsic &Int = *kv.second;
     if (Int.polymorphic()) {
       StringRef Name = Int.shortName();
-      if (ShortNamesSeen.find(std::string(Name)) == ShortNamesSeen.end()) {
+      if (ShortNamesSeen.insert(Name).second) {
         OS << "BUILTIN(__builtin_arm_mve_" << Name << ", \"vi.\", \"nt";
         if (Int.nonEvaluating())
           OS << "u"; // indicate that this builtin doesn't evaluate its args
         OS << "\")\n";
-        ShortNamesSeen.insert(std::string(Name));
       }
     }
   }


        


More information about the cfe-commits mailing list