From 5f5bcaec051fc4383d763e0be8ef2c866b841fdb Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Mon, 3 Mar 2025 07:43:18 -0800 Subject: [PATCH] [TableGen] Avoid repeated hash lookups (NFC) --- .../TableGen/Common/GlobalISel/GlobalISelMatchTable.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/llvm/utils/TableGen/Common/GlobalISel/GlobalISelMatchTable.cpp b/llvm/utils/TableGen/Common/GlobalISel/GlobalISelMatchTable.cpp index 21db090f62cce..4c809b4016cbd 100644 --- a/llvm/utils/TableGen/Common/GlobalISel/GlobalISelMatchTable.cpp +++ b/llvm/utils/TableGen/Common/GlobalISel/GlobalISelMatchTable.cpp @@ -834,7 +834,9 @@ Error RuleMatcher::defineComplexSubOperand(StringRef SymbolicName, unsigned SubOperandID, StringRef ParentSymbolicName) { std::string ParentName(ParentSymbolicName); - if (ComplexSubOperands.count(SymbolicName)) { + auto [It, Inserted] = ComplexSubOperands.try_emplace( + SymbolicName, ComplexPattern, RendererID, SubOperandID); + if (!Inserted) { const std::string &RecordedParentName = ComplexSubOperandsParentName[SymbolicName]; if (RecordedParentName != ParentName) @@ -847,7 +849,6 @@ Error RuleMatcher::defineComplexSubOperand(StringRef SymbolicName, return Error::success(); } - ComplexSubOperands[SymbolicName] = {ComplexPattern, RendererID, SubOperandID}; ComplexSubOperandsParentName[SymbolicName] = std::move(ParentName); return Error::success();