[Mlir-commits] [mlir] [Affine] Avoid repeated hash lookups (NFC) (PR #111330)
Kazu Hirata
llvmlistbot at llvm.org
Mon Oct 7 06:59:15 PDT 2024
================
@@ -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);
----------------
kazutakahirata wrote:
Yeah, it's safe but confusing. Personally, when I see `std::move`, I don't want to see any use until the end of the scope.
https://github.com/llvm/llvm-project/pull/111330
More information about the Mlir-commits
mailing list