[Mlir-commits] [mlir] Cache name collision counter in DialectResourceBlobManager (PR #215771)

Andrei Golubev llvmlistbot at llvm.org
Fri Aug 14 05:07:35 PDT 2026


================
@@ -53,7 +53,9 @@ auto DialectResourceBlobManager::insert(StringRef name,
   // re-attempt insertion until we find one that is unique.
   llvm::SmallString<32> nameStorage(name);
   nameStorage.push_back('_');
-  size_t nameCounter = 1;
+
+  // Resume the numbering from the last counter used for this base name.
+  size_t &nameCounter = nameCounters.try_emplace(name, 1).first->second;
----------------
andrey-golubev wrote:

nitpick: I guess you can just use:
```suggestion
  size_t &nameCounter = nameCounters[name];
```
the value should be zero-initialized if it's not present.

https://github.com/llvm/llvm-project/pull/215771


More information about the Mlir-commits mailing list