Skip to content

Commit 5e1e6a6

Browse files
[TableGen] Avoid repeated hash lookups (NFC) (llvm#107429)
1 parent 3f1d0e1 commit 5e1e6a6

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

mlir/lib/TableGen/Pattern.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,11 +137,10 @@ llvm::StringRef DagNode::getSymbol() const { return node->getNameStr(); }
137137

138138
Operator &DagNode::getDialectOp(RecordOperatorMap *mapper) const {
139139
llvm::Record *opDef = cast<llvm::DefInit>(node->getOperator())->getDef();
140-
auto it = mapper->find(opDef);
141-
if (it != mapper->end())
142-
return *it->second;
143-
return *mapper->try_emplace(opDef, std::make_unique<Operator>(opDef))
144-
.first->second;
140+
auto [it, inserted] = mapper->try_emplace(opDef);
141+
if (inserted)
142+
it->second = std::make_unique<Operator>(opDef);
143+
return *it->second;
145144
}
146145

147146
int DagNode::getNumOps() const {

0 commit comments

Comments
 (0)