diff options
author | nyamatongwe <unknown> | 2010-09-24 15:25:26 +1000 |
---|---|---|
committer | nyamatongwe <unknown> | 2010-09-24 15:25:26 +1000 |
commit | 582af035f6bca12900c782340f006977fadcaa22 (patch) | |
tree | e29dd0e3cbd7f362537fdfa6e0d8ff751444c247 /src/SplitVector.h | |
parent | 7fb06ca08a70dd9f9549b1e34c7dd38e9ca1413a (diff) | |
download | scintilla-mirror-582af035f6bca12900c782340f006977fadcaa22.tar.gz |
Added GetRange method to SplitVector as fast way to retrieve elements.
Diffstat (limited to 'src/SplitVector.h')
-rw-r--r-- | src/SplitVector.h | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/SplitVector.h b/src/SplitVector.h index 2c5c7a1d0..2e17ba3dc 100644 --- a/src/SplitVector.h +++ b/src/SplitVector.h @@ -238,6 +238,23 @@ public: DeleteRange(0, lengthBody); } + // Retrieve a range of elemetns into an array + void GetRange(T *buffer, int position, int retrieveLength) const { + // Split into up to 2 ranges, before and after the split then use memcpy on each. + int range1Length = 0; + if (position < part1Length) { + int part1AfterPosition = part1Length - position; + range1Length = retrieveLength; + if (range1Length > part1AfterPosition) + range1Length = part1AfterPosition; + } + memcpy(buffer, body + position, range1Length * sizeof(T)); + buffer += range1Length; + position = position + range1Length + gapLength; + int range2Length = retrieveLength - range1Length; + memcpy(buffer, body + position, range2Length * sizeof(T)); + } + T *BufferPointer() { RoomFor(1); GapTo(lengthBody); |