Skip to content

Commit 01eb071

Browse files
[mlir] Avoid repeated hash lookups (NFC) (#107519)
1 parent a37f7ae commit 01eb071

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

mlir/lib/IR/AttrTypeSubElements.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ WalkResult AttrTypeWalker::walkImpl(T element, WalkFns &walkFns,
2727
WalkOrder order) {
2828
// Check if we've already walk this element before.
2929
auto key = std::make_pair(element.getAsOpaquePointer(), (int)order);
30-
auto it = visitedAttrTypes.find(key);
31-
if (it != visitedAttrTypes.end())
30+
auto [it, inserted] =
31+
visitedAttrTypes.try_emplace(key, WalkResult::advance());
32+
if (!inserted)
3233
return it->second;
33-
visitedAttrTypes.try_emplace(key, WalkResult::advance());
3434

3535
// If we are walking in post order, walk the sub elements first.
3636
if (order == WalkOrder::PostOrder) {

0 commit comments

Comments
 (0)