diff options
author | Neil <nyamatongwe@gmail.com> | 2016-09-30 10:32:58 +1000 |
---|---|---|
committer | Neil <nyamatongwe@gmail.com> | 2016-09-30 10:32:58 +1000 |
commit | 03378bf5015987dd140d7fabd3d043ae909a4afc (patch) | |
tree | 51d96b5b07012161fc54b20d62edf68927e70833 /src/SplitVector.h | |
parent | 300629b456064ea2f89ec3ceb90ad8c74b8e500c (diff) | |
download | scintilla-mirror-03378bf5015987dd140d7fabd3d043ae909a4afc.tar.gz |
Enable SplitVector to store objects by using std::copy to copy elements instead
of memmove and memcpy.
This allows SplitVector<std::string> to work.
Diffstat (limited to 'src/SplitVector.h')
-rw-r--r-- | src/SplitVector.h | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/src/SplitVector.h b/src/SplitVector.h index 3153700f5..df722530e 100644 --- a/src/SplitVector.h +++ b/src/SplitVector.h @@ -29,15 +29,17 @@ protected: void GapTo(int position) { if (position != part1Length) { if (position < part1Length) { - memmove( - body + position + gapLength, + // Moving the gap towards start so moving elements towards end + std::copy_backward( body + position, - sizeof(T) * (part1Length - position)); - } else { // position > part1Length - memmove( body + part1Length, + body + gapLength + part1Length); + } else { // position > part1Length + // Moving the gap towards end so moving elements towards start + std::copy( body + part1Length + gapLength, - sizeof(T) * (position - part1Length)); + body + gapLength + position, + body + part1Length); } part1Length = position; } @@ -93,7 +95,7 @@ public: GapTo(lengthBody); T *newBody = new T[newSize]; if ((size != 0) && (body != 0)) { - memmove(newBody, body, sizeof(T) * lengthBody); + std::copy(body, body + lengthBody, newBody); delete []body; } body = newBody; @@ -205,7 +207,7 @@ public: } RoomFor(insertLength); GapTo(positionToInsert); - memmove(body + part1Length, s + positionFrom, sizeof(T) * insertLength); + std::copy(s + positionFrom, s + positionFrom + insertLength, body + part1Length); lengthBody += insertLength; part1Length += insertLength; gapLength -= insertLength; @@ -254,11 +256,11 @@ public: if (range1Length > part1AfterPosition) range1Length = part1AfterPosition; } - memcpy(buffer, body + position, range1Length * sizeof(T)); + std::copy(body + position, body + position + range1Length, buffer); buffer += range1Length; position = position + range1Length + gapLength; int range2Length = retrieveLength - range1Length; - memcpy(buffer, body + position, range2Length * sizeof(T)); + std::copy(body + position, body + position + range2Length, buffer); } T *BufferPointer() { |