[Mlir-commits] [mlir] [mlir] Avoid repeated map lookups (NFC) (PR #113074)
Nikita Popov
llvmlistbot at llvm.org
Sun Oct 20 00:37:16 PDT 2024
================
@@ -1160,9 +1160,8 @@ bool mlir::sparse_tensor::isBlockSparsity(AffineMap dimToLvl) {
} else if (auto dimOp = dyn_cast<AffineDimExpr>(result)) {
auto pos = dimOp.getPosition();
// Expect dim to be unset.
- if (coeffientMap.find(pos) != coeffientMap.end())
+ if (!coeffientMap.try_emplace(pos).second)
----------------
nikic wrote:
```suggestion
if (!coeffientMap.try_emplace(pos, 0).second)
```
I'd make the value explicit in this context...
https://github.com/llvm/llvm-project/pull/113074
More information about the Mlir-commits
mailing list