File tree Expand file tree Collapse file tree 2 files changed +13
-12
lines changed Expand file tree Collapse file tree 2 files changed +13
-12
lines changed Original file line number Diff line number Diff line change @@ -156,6 +156,10 @@ class SmallPtrSetImplBase : public DebugEpochBase {
156156 return {CurArray, CurArray + NumNonEmpty};
157157 }
158158
159+ iterator_range<const void **> buckets () {
160+ return make_range (CurArray, EndPointer ());
161+ }
162+
159163 // / insert_imp - This returns true if the pointer was new to the set, false if
160164 // / it was already in the set. This is hidden from the client so that the
161165 // / derived class can check that the right type of pointer is passed in.
@@ -441,13 +445,12 @@ class SmallPtrSetImpl : public SmallPtrSetImplBase {
441445 return Removed;
442446 }
443447
444- for (const void **APtr = CurArray, **E = EndPointer (); APtr != E; ++APtr) {
445- const void *Value = *APtr;
446- if (Value == getTombstoneMarker () || Value == getEmptyMarker ())
448+ for (const void *&Bucket : buckets ()) {
449+ if (Bucket == getTombstoneMarker () || Bucket == getEmptyMarker ())
447450 continue ;
448- PtrType Ptr = PtrTraits::getFromVoidPointer (const_cast <void *>(Value ));
451+ PtrType Ptr = PtrTraits::getFromVoidPointer (const_cast <void *>(Bucket ));
449452 if (P (Ptr)) {
450- *APtr = getTombstoneMarker ();
453+ Bucket = getTombstoneMarker ();
451454 ++NumTombstones;
452455 incrementEpoch ();
453456 Removed = true ;
Original file line number Diff line number Diff line change @@ -110,8 +110,7 @@ const void *const *SmallPtrSetImplBase::FindBucketFor(const void *Ptr) const {
110110// / Grow - Allocate a larger backing store for the buckets and move it over.
111111// /
112112void SmallPtrSetImplBase::Grow (unsigned NewSize) {
113- const void **OldBuckets = CurArray;
114- const void **OldEnd = EndPointer ();
113+ auto OldBuckets = buckets ();
115114 bool WasSmall = isSmall ();
116115
117116 // Install the new array. Clear all the buckets to empty.
@@ -123,15 +122,14 @@ void SmallPtrSetImplBase::Grow(unsigned NewSize) {
123122 memset (CurArray, -1 , NewSize*sizeof (void *));
124123
125124 // Copy over all valid entries.
126- for (const void **BucketPtr = OldBuckets; BucketPtr != OldEnd; ++BucketPtr ) {
125+ for (const void *&Bucket : OldBuckets) {
127126 // Copy over the element if it is valid.
128- const void *Elt = *BucketPtr;
129- if (Elt != getTombstoneMarker () && Elt != getEmptyMarker ())
130- *const_cast <void **>(FindBucketFor (Elt)) = const_cast <void *>(Elt);
127+ if (Bucket != getTombstoneMarker () && Bucket != getEmptyMarker ())
128+ *const_cast <void **>(FindBucketFor (Bucket)) = const_cast <void *>(Bucket);
131129 }
132130
133131 if (!WasSmall)
134- free (OldBuckets);
132+ free (OldBuckets. begin () );
135133 NumNonEmpty -= NumTombstones;
136134 NumTombstones = 0 ;
137135 IsSmall = false ;
You can’t perform that action at this time.
0 commit comments