[llvm] [AsmParser] Avoid repeated map lookups (NFC) (PR #128629)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 24 21:35:55 PST 2025
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/128629
None
>From 9054afd565fb45358386291c87b4077d23c6cef1 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Mon, 24 Feb 2025 01:02:33 -0800
Subject: [PATCH] [AsmParser] Avoid repeated map lookups (NFC)
---
llvm/lib/AsmParser/LLParser.cpp | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
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