[llvm] 7501c9c - [AsmParser] Avoid repeated map lookups (NFC) (#128629)

via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 25 09:01:38 PST 2025


Author: Kazu Hirata
Date: 2025-02-25T09:01:34-08:00
New Revision: 7501c9c0e124139198cf84148a49fe80b9f64cea

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

LOG: [AsmParser] Avoid repeated map lookups (NFC) (#128629)

Added: 
    

Modified: 
    llvm/lib/AsmParser/LLParser.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/AsmParser/LLParser.cpp b/llvm/lib/AsmParser/LLParser.cpp
index 2e8487db45f64..690e92a0f2afc 100644
--- a/llvm/lib/AsmParser/LLParser.cpp
+++ b/llvm/lib/AsmParser/LLParser.cpp
@@ -1036,9 +1036,10 @@ bool LLParser::parseStandaloneMetadata() {
 
     assert(NumberedMetadata[MetadataID] == Init && "Tracking VH didn't work");
   } else {
-    if (NumberedMetadata.count(MetadataID))
+    auto [It, Inserted] = NumberedMetadata.try_emplace(MetadataID);
+    if (!Inserted)
       return tokError("Metadata id is already used");
-    NumberedMetadata[MetadataID].reset(Init);
+    It->second.reset(Init);
   }
 
   return false;


        


More information about the llvm-commits mailing list