diff options
author | Neil <nyamatongwe@gmail.com> | 2018-01-26 18:04:38 +1100 |
---|---|---|
committer | Neil <nyamatongwe@gmail.com> | 2018-01-26 18:04:38 +1100 |
commit | 8658d9b4ce85c12fe03876a5250e724780872407 (patch) | |
tree | 915599c2d99d2c763679dbb93a863206c5704d89 /src/Partitioning.h | |
parent | 4a5e9654ce0c4a6cd6c1aff452f8f9344a9849a6 (diff) | |
download | scintilla-mirror-8658d9b4ce85c12fe03876a5250e724780872407.tar.gz |
Extend SplitVector to allow more than 2 billion elements on 64-bit systems.
Diffstat (limited to 'src/Partitioning.h')
-rw-r--r-- | src/Partitioning.h | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/src/Partitioning.h b/src/Partitioning.h index 07d093ea2..85e00b328 100644 --- a/src/Partitioning.h +++ b/src/Partitioning.h @@ -16,7 +16,7 @@ namespace Scintilla { class SplitVectorWithRangeAdd : public SplitVector<int> { public: - explicit SplitVectorWithRangeAdd(int growSize_) { + explicit SplitVectorWithRangeAdd(ptrdiff_t growSize_) { SetGrowSize(growSize_); ReAllocate(growSize_); } @@ -25,12 +25,12 @@ public: void operator=(const SplitVectorWithRangeAdd &) = delete; ~SplitVectorWithRangeAdd() { } - void RangeAddDelta(int start, int end, int delta) { + void RangeAddDelta(ptrdiff_t start, ptrdiff_t end, int delta) { // end is 1 past end, so end-start is number of elements to change - int i = 0; - const int rangeLength = end - start; - int range1Length = rangeLength; - const int part1Left = part1Length - start; + ptrdiff_t i = 0; + const ptrdiff_t rangeLength = end - start; + ptrdiff_t range1Length = rangeLength; + const ptrdiff_t part1Left = part1Length - start; if (range1Length > part1Left) range1Length = part1Left; while (i < range1Length) { @@ -67,7 +67,7 @@ private: } stepPartition = partitionUpTo; if (stepPartition >= body->Length()-1) { - stepPartition = body->Length()-1; + stepPartition = Partitions(); stepLength = 0; } } @@ -80,7 +80,7 @@ private: stepPartition = partitionDownTo; } - void Allocate(int growSize) { + void Allocate(ptrdiff_t growSize) { body.reset(new SplitVectorWithRangeAdd(growSize)); stepPartition = 0; stepLength = 0; @@ -101,7 +101,7 @@ public: } int Partitions() const { - return body->Length()-1; + return static_cast<int>(body->Length()-1); } void InsertPartition(int partition, int pos) { @@ -132,7 +132,7 @@ public: BackStep(partitionInsert); stepLength += delta; } else { - ApplyStep(body->Length()-1); + ApplyStep(Partitions()); stepPartition = partitionInsert; stepLength = delta; } @@ -168,10 +168,10 @@ public: int PartitionFromPosition(int pos) const { if (body->Length() <= 1) return 0; - if (pos >= (PositionFromPartition(body->Length()-1))) - return body->Length() - 1 - 1; + if (pos >= (PositionFromPartition(Partitions()))) + return Partitions() - 1; int lower = 0; - int upper = body->Length()-1; + int upper = Partitions(); do { const int middle = (upper + lower + 1) / 2; // Round high int posMiddle = body->ValueAt(middle); |