[mlir] Avoid repeated hash lookups (NFC) (#107519)

This commit is contained in:
Kazu Hirata
2024-09-06 07:48:39 -07:00
committed by GitHub
parent a37f7ae626
commit 01eb071de0

View File

@@ -27,10 +27,10 @@ WalkResult AttrTypeWalker::walkImpl(T element, WalkFns &walkFns,
WalkOrder order) {
// Check if we've already walk this element before.
auto key = std::make_pair(element.getAsOpaquePointer(), (int)order);
auto it = visitedAttrTypes.find(key);
if (it != visitedAttrTypes.end())
auto [it, inserted] =
visitedAttrTypes.try_emplace(key, WalkResult::advance());
if (!inserted)
return it->second;
visitedAttrTypes.try_emplace(key, WalkResult::advance());
// If we are walking in post order, walk the sub elements first.
if (order == WalkOrder::PostOrder) {