aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--src/SplitVector.h17
1 files changed, 7 insertions, 10 deletions
diff --git a/src/SplitVector.h b/src/SplitVector.h
index d233a50ed..adaa8eeb8 100644
--- a/src/SplitVector.h
+++ b/src/SplitVector.h
@@ -19,7 +19,7 @@ protected:
ptrdiff_t lengthBody;
ptrdiff_t part1Length;
ptrdiff_t gapLength; /// invariant: gapLength == body.size() - lengthBody
- ptrdiff_t growSize;
+ size_t growSize;
/// Move the gap to a particular position so that insertion and
/// deletion at that point will not require much copying and
@@ -54,7 +54,7 @@ protected:
/// reallocating if more space needed.
void RoomFor(ptrdiff_t insertionLength) {
if (gapLength < insertionLength) {
- while (growSize < static_cast<ptrdiff_t>(body.size() / 6))
+ while (growSize < body.size() / 6)
growSize *= 2;
ReAllocate(body.size() + insertionLength + growSize);
}
@@ -83,25 +83,22 @@ public:
~SplitVector() {
}
- ptrdiff_t GetGrowSize() const noexcept {
+ size_t GetGrowSize() const noexcept {
return growSize;
}
- void SetGrowSize(ptrdiff_t growSize_) noexcept {
+ void SetGrowSize(size_t growSize_) noexcept {
growSize = growSize_;
}
/// Reallocate the storage for the buffer to be newSize and
/// copy existing contents to the new buffer.
/// Must not be used to decrease the size of the buffer.
- void ReAllocate(ptrdiff_t newSize) {
- if (newSize < 0)
- throw std::runtime_error("SplitVector::ReAllocate: negative size.");
-
- if (newSize > static_cast<ptrdiff_t>(body.size())) {
+ void ReAllocate(size_t newSize) {
+ if (newSize > body.size()) {
// Move the gap to the end
GapTo(lengthBody);
- gapLength += newSize - static_cast<ptrdiff_t>(body.size());
+ gapLength += newSize - body.size();
// RoomFor implements a growth strategy but so does vector::resize so
// ensure vector::resize allocates exactly the amount wanted by
// calling reserve first.