diff options
| author | Neil <nyamatongwe@gmail.com> | 2020-05-02 09:01:54 +1000 |
|---|---|---|
| committer | Neil <nyamatongwe@gmail.com> | 2020-05-02 09:01:54 +1000 |
| commit | c0c411daf8adbbeeb3a92a57d6e1538e58a49587 (patch) | |
| tree | ffeb0ba0c2ff07018dac09190043816ab67a4655 /src | |
| parent | 90ff87db7b368addb01191205570ba71054986e7 (diff) | |
| download | scintilla-mirror-c0c411daf8adbbeeb3a92a57d6e1538e58a49587.tar.gz | |
Backport: InsertEmpty now returns a pointer to the newly added elements to allow caller to
efficiently set those elements.
Backport of changeset 8225:de663ebc1bc6.
Diffstat (limited to 'src')
| -rw-r--r-- | src/SplitVector.h | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/SplitVector.h b/src/SplitVector.h index fcd8b0d0e..e805c50dc 100644 --- a/src/SplitVector.h +++ b/src/SplitVector.h @@ -206,11 +206,12 @@ public: /// Add some new empty elements. /// InsertValue is good for value objects but not for unique_ptr objects /// since they can only be moved from once. - void InsertEmpty(ptrdiff_t position, ptrdiff_t insertLength) { + /// Callers can write to the returned pointer to transform inputs without copies. + T *InsertEmpty(ptrdiff_t position, ptrdiff_t insertLength) { PLATFORM_ASSERT((position >= 0) && (position <= lengthBody)); if (insertLength > 0) { if ((position < 0) || (position > lengthBody)) { - return; + return nullptr; } RoomFor(insertLength); GapTo(position); @@ -222,6 +223,7 @@ public: part1Length += insertLength; gapLength -= insertLength; } + return body.data() + position; } /// Ensure at least length elements allocated, |
