[llvm-commits] [llvm] r42604 - /llvm/trunk/include/llvm/ADT/SparseBitVector.h
Daniel Berlin
dberlin at dberlin.org
Wed Oct 3 22:25:51 PDT 2007
Author: dannyb
Date: Thu Oct 4 00:25:51 2007
New Revision: 42604
URL: http://llvm.org/viewvc/llvm-project?rev=42604&view=rev
Log:
Make SparseBitVector::set actually work properly when sets are not in ascending or descending order.
Modified:
llvm/trunk/include/llvm/ADT/SparseBitVector.h
Modified: llvm/trunk/include/llvm/ADT/SparseBitVector.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/SparseBitVector.h?rev=42604&r1=42603&r2=42604&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/SparseBitVector.h (original)
+++ llvm/trunk/include/llvm/ADT/SparseBitVector.h Thu Oct 4 00:25:51 2007
@@ -334,9 +334,8 @@
--ElementIter;
} else {
while (ElementIter != Elements.end() &&
- ElementIter->index() <= ElementIndex)
+ ElementIter->index() < ElementIndex)
++ElementIter;
- --ElementIter;
}
CurrElementIter = ElementIter;
return ElementIter;
@@ -536,10 +535,17 @@
if (ElementIter == Elements.end() ||
ElementIter->index() != ElementIndex) {
Element = new SparseBitVectorElement<ElementSize>(ElementIndex);
- // Insert does insert before, and lower bound gives the one before.
- ElementIter = Elements.insert(++ElementIter, Element);
+ // We may have hit the beginning of our SparseBitVector, in which case,
+ // we may need to insert right after this element, which requires moving
+ // the current iterator forward one, because insert does insert before.
+ if (ElementIter->index() < ElementIndex)
+ ElementIter = Elements.insert(++ElementIter, Element);
+ else
+ ElementIter = Elements.insert(ElementIter, Element);
}
}
+ CurrElementIter = ElementIter;
+
ElementIter->set(Idx % ElementSize);
}
More information about the llvm-commits
mailing list