aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorNeil <nyamatongwe@gmail.com>2020-05-02 09:01:54 +1000
committerNeil <nyamatongwe@gmail.com>2020-05-02 09:01:54 +1000
commit4535b0d9ce9c3be4bb9a02973485427ae67e61d9 (patch)
tree43689d33f07e3c3518e9706d25040672bc288551 /src
parent436402964655f4816e9526b804a5f19b273d6adc (diff)
downloadscintilla-mirror-4535b0d9ce9c3be4bb9a02973485427ae67e61d9.tar.gz
InsertEmpty now returns a pointer to the newly added elements to allow caller to
efficiently set those elements.
Diffstat (limited to 'src')
-rw-r--r--src/SplitVector.h6
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,