Skip to content

Commit 9372d1d

Browse files
[TableGen] Avoid repeated hash lookups (NFC) (llvm#129655)
1 parent ef94d8a commit 9372d1d

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

llvm/utils/TableGen/Common/GlobalISel/GlobalISelMatchTable.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -834,7 +834,9 @@ Error RuleMatcher::defineComplexSubOperand(StringRef SymbolicName,
834834
unsigned SubOperandID,
835835
StringRef ParentSymbolicName) {
836836
std::string ParentName(ParentSymbolicName);
837-
if (ComplexSubOperands.count(SymbolicName)) {
837+
auto [It, Inserted] = ComplexSubOperands.try_emplace(
838+
SymbolicName, ComplexPattern, RendererID, SubOperandID);
839+
if (!Inserted) {
838840
const std::string &RecordedParentName =
839841
ComplexSubOperandsParentName[SymbolicName];
840842
if (RecordedParentName != ParentName)
@@ -847,7 +849,6 @@ Error RuleMatcher::defineComplexSubOperand(StringRef SymbolicName,
847849
return Error::success();
848850
}
849851

850-
ComplexSubOperands[SymbolicName] = {ComplexPattern, RendererID, SubOperandID};
851852
ComplexSubOperandsParentName[SymbolicName] = std::move(ParentName);
852853

853854
return Error::success();

0 commit comments

Comments
 (0)