[llvm] efae9f3 - [MIRParser] Avoid repeated map lookups (NFC) (#123561)

via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 20 10:15:29 PST 2025


Author: Kazu Hirata
Date: 2025-01-20T10:15:27-08:00
New Revision: efae9f3c2192e72cf753f2e29fd930e14e4fdd90

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

LOG: [MIRParser] Avoid repeated map lookups (NFC) (#123561)

Added: 
    

Modified: 
    llvm/lib/CodeGen/MIRParser/MIParser.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/CodeGen/MIRParser/MIParser.cpp b/llvm/lib/CodeGen/MIRParser/MIParser.cpp
index f77c4613ad801b..19c73374c3703d 100644
--- a/llvm/lib/CodeGen/MIRParser/MIParser.cpp
+++ b/llvm/lib/CodeGen/MIRParser/MIParser.cpp
@@ -1316,9 +1316,10 @@ bool MIParser::parseMachineMetadata() {
 
     assert(PFS.MachineMetadataNodes[ID] == MD && "Tracking VH didn't work");
   } else {
-    if (PFS.MachineMetadataNodes.count(ID))
+    auto [It, Inserted] = PFS.MachineMetadataNodes.try_emplace(ID);
+    if (!Inserted)
       return error("Metadata id is already used");
-    PFS.MachineMetadataNodes[ID].reset(MD);
+    It->second.reset(MD);
   }
 
   return false;


        


More information about the llvm-commits mailing list