Skip to content

Commit c70b9c8

Browse files
[ADT] Use range-based for loops in SparseBitVector.h (NFC) (#158408)
1 parent 9b70b84 commit c70b9c8

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

llvm/include/llvm/ADT/SparseBitVector.h

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,8 @@ template <unsigned ElementSize = 128> struct SparseBitVectorElement {
119119

120120
size_type count() const {
121121
unsigned NumBits = 0;
122-
for (unsigned i = 0; i < BITWORDS_PER_ELEMENT; ++i)
123-
NumBits += llvm::popcount(Bits[i]);
122+
for (BitWord Bit : Bits)
123+
NumBits += llvm::popcount(Bit);
124124
return NumBits;
125125
}
126126

@@ -799,11 +799,8 @@ class SparseBitVector {
799799

800800
unsigned count() const {
801801
unsigned BitCount = 0;
802-
for (ElementListConstIter Iter = Elements.begin();
803-
Iter != Elements.end();
804-
++Iter)
805-
BitCount += Iter->count();
806-
802+
for (const SparseBitVectorElement<ElementSize> &Elem : Elements)
803+
BitCount += Elem.count();
807804
return BitCount;
808805
}
809806

0 commit comments

Comments
 (0)