summaryrefslogtreecommitdiff
path: root/include/llvm/ADT/SparseBitVector.h
diff options
context:
space:
mode:
authorDaniel Berlin <dberlin@dberlin.org>2007-10-04 21:27:17 +0000
committerDaniel Berlin <dberlin@dberlin.org>2007-10-04 21:27:17 +0000
commit08bb6998437528143934de9c76fa312e48e58896 (patch)
tree3dd488d56b966ab4ce5276c1989e45f7952f6478 /include/llvm/ADT/SparseBitVector.h
parent9d03724c8c348dd31cc5b692b08b23c67fd4b0a0 (diff)
downloadllvm-08bb6998437528143934de9c76fa312e48e58896.tar.gz
llvm-08bb6998437528143934de9c76fa312e48e58896.tar.bz2
llvm-08bb6998437528143934de9c76fa312e48e58896.tar.xz
Fix the previous bug a slightly different way (by modifying how find_next works)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42613 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/ADT/SparseBitVector.h')
-rw-r--r--include/llvm/ADT/SparseBitVector.h17
1 files changed, 8 insertions, 9 deletions
diff --git a/include/llvm/ADT/SparseBitVector.h b/include/llvm/ADT/SparseBitVector.h
index 56db805647..1d96546954 100644
--- a/include/llvm/ADT/SparseBitVector.h
+++ b/include/llvm/ADT/SparseBitVector.h
@@ -168,15 +168,14 @@ public:
assert(0 && "Illegal empty element");
}
- /// find_next - Returns the index of the next set bit following the
- /// "Prev" bit. Returns -1 if the next set bit is not found.
- int find_next(unsigned Prev) const {
- ++Prev;
- if (Prev >= BITS_PER_ELEMENT)
+ /// find_next - Returns the index of the next set bit starting from the
+ /// "Curr" bit. Returns -1 if the next set bit is not found.
+ int find_next(unsigned Curr) const {
+ if (Curr >= BITS_PER_ELEMENT)
return -1;
- unsigned WordPos = Prev / BITWORD_SIZE;
- unsigned BitPos = Prev % BITWORD_SIZE;
+ unsigned WordPos = Curr / BITWORD_SIZE;
+ unsigned BitPos = Curr % BITWORD_SIZE;
BitWord Copy = Bits[WordPos];
assert (WordPos <= BITWORDS_PER_ELEMENT
&& "Word Position outside of element");
@@ -390,7 +389,7 @@ class SparseBitVector {
// See if we ran out of Bits in this word.
if (!Bits) {
- int NextSetBitNumber = Iter->find_next((BitNumber - 1) % ElementSize) ;
+ int NextSetBitNumber = Iter->find_next(BitNumber % ElementSize) ;
// If we ran out of set bits in this element, move to next element.
if (NextSetBitNumber == -1 || (BitNumber % ElementSize == 0)) {
++Iter;
@@ -546,7 +545,7 @@ public:
}
}
CurrElementIter = ElementIter;
-
+
ElementIter->set(Idx % ElementSize);
}