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 {
156
156
return {CurArray, CurArray + NumNonEmpty};
157
157
}
158
158
159
+ iterator_range<const void **> buckets () {
160
+ return make_range (CurArray, EndPointer ());
161
+ }
162
+
159
163
// / insert_imp - This returns true if the pointer was new to the set, false if
160
164
// / it was already in the set. This is hidden from the client so that the
161
165
// / derived class can check that the right type of pointer is passed in.
@@ -441,13 +445,12 @@ class SmallPtrSetImpl : public SmallPtrSetImplBase {
441
445
return Removed;
442
446
}
443
447
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 ())
447
450
continue ;
448
- PtrType Ptr = PtrTraits::getFromVoidPointer (const_cast <void *>(Value ));
451
+ PtrType Ptr = PtrTraits::getFromVoidPointer (const_cast <void *>(Bucket ));
449
452
if (P (Ptr)) {
450
- *APtr = getTombstoneMarker ();
453
+ Bucket = getTombstoneMarker ();
451
454
++NumTombstones;
452
455
incrementEpoch ();
453
456
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 {
110
110
// / Grow - Allocate a larger backing store for the buckets and move it over.
111
111
// /
112
112
void SmallPtrSetImplBase::Grow (unsigned NewSize) {
113
- const void **OldBuckets = CurArray;
114
- const void **OldEnd = EndPointer ();
113
+ auto OldBuckets = buckets ();
115
114
bool WasSmall = isSmall ();
116
115
117
116
// Install the new array. Clear all the buckets to empty.
@@ -123,15 +122,14 @@ void SmallPtrSetImplBase::Grow(unsigned NewSize) {
123
122
memset (CurArray, -1 , NewSize*sizeof (void *));
124
123
125
124
// Copy over all valid entries.
126
- for (const void **BucketPtr = OldBuckets; BucketPtr != OldEnd; ++BucketPtr ) {
125
+ for (const void *&Bucket : OldBuckets) {
127
126
// 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);
131
129
}
132
130
133
131
if (!WasSmall)
134
- free (OldBuckets);
132
+ free (OldBuckets. begin () );
135
133
NumNonEmpty -= NumTombstones;
136
134
NumTombstones = 0 ;
137
135
IsSmall = false ;
You can’t perform that action at this time.
0 commit comments