[Mlir-commits] [mlir] [Affine] Avoid repeated hash lookups (NFC) (PR #111330)
Kazu Hirata
llvmlistbot at llvm.org
Sun Oct 6 19:34:45 PDT 2024
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/111330
None
>From c115f039804c406fc8a612a39d7f4d01dc5ea47f Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Sun, 6 Oct 2024 09:27:24 -0700
Subject: [PATCH] [Affine] Avoid repeated hash lookups (NFC)
---
mlir/lib/Dialect/Affine/Analysis/Utils.cpp | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/mlir/lib/Dialect/Affine/Analysis/Utils.cpp b/mlir/lib/Dialect/Affine/Analysis/Utils.cpp
index 194ee9115e3d7a..29608647d85746 100644
--- a/mlir/lib/Dialect/Affine/Analysis/Utils.cpp
+++ b/mlir/lib/Dialect/Affine/Analysis/Utils.cpp
@@ -1927,9 +1927,9 @@ static std::optional<int64_t> getMemoryFootprintBytes(Block &block,
return opInst->emitError("error obtaining memory region\n");
}
- auto it = regions.find(region->memref);
- if (it == regions.end()) {
- regions[region->memref] = std::move(region);
+ auto [it, inserted] = regions.try_emplace(region->memref);
+ if (inserted) {
+ it->second = std::move(region);
} else if (failed(it->second->unionBoundingBox(*region))) {
return opInst->emitWarning(
"getMemoryFootprintBytes: unable to perform a union on a memory "
More information about the Mlir-commits
mailing list