@@ -89,6 +89,10 @@ class StringMapImpl {
89
89
// / setup the map as empty.
90
90
LLVM_ABI void init (unsigned Size);
91
91
92
+ iterator_range<StringMapEntryBase **> buckets () {
93
+ return make_range (TheTable, TheTable + NumBuckets);
94
+ }
95
+
92
96
public:
93
97
static constexpr uintptr_t TombstoneIntVal =
94
98
static_cast <uintptr_t >(-1 )
@@ -198,8 +202,7 @@ class LLVM_ALLOCATORHOLDER_EMPTYBASE StringMap
198
202
// to default values. This is a copy of clear(), but avoids unnecessary
199
203
// work not required in the destructor.
200
204
if (!empty ()) {
201
- for (unsigned I = 0 , E = NumBuckets; I != E; ++I) {
202
- StringMapEntryBase *Bucket = TheTable[I];
205
+ for (StringMapEntryBase *Bucket : buckets ()) {
203
206
if (Bucket && Bucket != getTombstoneVal ()) {
204
207
static_cast <MapEntryTy *>(Bucket)->Destroy (getAllocator ());
205
208
}
@@ -398,8 +401,7 @@ class LLVM_ALLOCATORHOLDER_EMPTYBASE StringMap
398
401
399
402
// Zap all values, resetting the keys back to non-present (not tombstone),
400
403
// which is safe because we're removing all elements.
401
- for (unsigned I = 0 , E = NumBuckets; I != E; ++I) {
402
- StringMapEntryBase *&Bucket = TheTable[I];
404
+ for (StringMapEntryBase *&Bucket : buckets ()) {
403
405
if (Bucket && Bucket != getTombstoneVal ()) {
404
406
static_cast <MapEntryTy *>(Bucket)->Destroy (getAllocator ());
405
407
}
0 commit comments