[llvm] [ADT] Refactor DenseMap::insert, try_emplace, and operator[] (NFC) (PR #155204)

Jakub Kuderski via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 25 07:10:05 PDT 2025


================
@@ -496,6 +475,18 @@ class DenseMapBase : public DebugEpochBase {
   static const KeyT getTombstoneKey() { return KeyInfoT::getTombstoneKey(); }
 
 private:
+  template <typename KeyArgT, typename... Ts>
+  std::pair<iterator, bool> try_emplace_impl(KeyArgT &&Key, Ts &&...Args) {
+    BucketT *TheBucket;
+    if (LookupBucketFor(Key, TheBucket))
+      return {makeInsertIterator(TheBucket), false}; // Already in map.
----------------
kuhar wrote:

```suggestion
      return {makeInsertIterator(TheBucket), false}; // Already in the map.
```

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


More information about the llvm-commits mailing list