[llvm] [FoldingSet] Switch to linear probing and Algorithm R deletion (PR #218190)

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 26 10:54:45 PDT 2026


================
@@ -497,21 +502,17 @@ class FoldingSetImpl : public FoldingSetBase, public Trait::ContextStorage {
 public:
   using iterator = FoldingSetIterator<T>;
 
-  iterator begin() { return iterator(this, Buckets); }
-  iterator end() { return iterator(this, Buckets + NumBuckets); }
+  iterator begin() { return iterator(this, 0); }
+  iterator end() { return iterator(this, NumBuckets); }
 
   using const_iterator = FoldingSetIterator<const T>;
 
-  const_iterator begin() const { return const_iterator(this, Buckets); }
-  const_iterator end() const {
-    return const_iterator(this, Buckets + NumBuckets);
-  }
+  const_iterator begin() const { return const_iterator(this, 0); }
+  const_iterator end() const { return const_iterator(this, NumBuckets); }
 
-  /// Grow the number of buckets so that we can hold at least \p EltCount
-  /// nodes before rebucketing. May allocate more space than requested.
-  void reserve(unsigned EltCount) {
-    FoldingSetBase::reserve(EltCount, getFoldingSetInfo());
-  }
+  /// Grow the number of buckets so that we can hold at least \p N nodes
+  /// before rebucketing. May allocate more space than requested.
+  void reserve(unsigned N) { FoldingSetBase::reserve(N); }
----------------
MaskRay wrote:

Moved to public. Thanks!

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


More information about the llvm-commits mailing list