diff options
author | Neil <nyamatongwe@gmail.com> | 2021-07-15 14:04:44 +1000 |
---|---|---|
committer | Neil <nyamatongwe@gmail.com> | 2021-07-15 14:04:44 +1000 |
commit | 65ea703cfbf8d5660c59e8b1ab756ed7ddde50a9 (patch) | |
tree | e58a68dcffce08cd7dadc1686d592896d5b90c28 /src/CellBuffer.cxx | |
parent | 0a5f16edd287fba222214b89661285191e7af898 (diff) | |
download | scintilla-mirror-65ea703cfbf8d5660c59e8b1ab756ed7ddde50a9.tar.gz |
Feature [feature-requests:#1381] Move SplitView to header so it can be used more
widely.
Ensure that case where all text is after the gap is as efficient as when all
text is before the gap.
Diffstat (limited to 'src/CellBuffer.cxx')
-rw-r--r-- | src/CellBuffer.cxx | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/CellBuffer.cxx b/src/CellBuffer.cxx index 375fe2201..f02d5348a 100644 --- a/src/CellBuffer.cxx +++ b/src/CellBuffer.cxx @@ -642,6 +642,21 @@ Sci::Position CellBuffer::GapPosition() const noexcept { return substance.GapPosition(); } +SplitView CellBuffer::AllView() const noexcept { + const size_t length = substance.Length(); + size_t length1 = substance.GapPosition(); + if (length1 == 0) { + // Assign segment2 to segment1 / length1 to avoid useless test against 0 length1 + length1 = length; + } + return SplitView { + substance.ElementPointer(0), + length1, + substance.ElementPointer(length1) - length1, + length + }; +} + // The char* returned is to an allocation owned by the undo history const char *CellBuffer::InsertString(Sci::Position position, const char *s, Sci::Position insertLength, bool &startSequence) { // InsertString and DeleteChars are the bottleneck though which all changes occur |