[llvm] [MIRParser] Avoid repeated map lookups (NFC) (PR #123561)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Sun Jan 19 23:55:33 PST 2025
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/123561
None
>From 850342cc0e51787058af57c6738675d125d7b97f Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Sun, 19 Jan 2025 12:03:35 -0800
Subject: [PATCH] [MIRParser] Avoid repeated map lookups (NFC)
---
llvm/lib/CodeGen/MIRParser/MIParser.cpp | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
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