From 65ea703cfbf8d5660c59e8b1ab756ed7ddde50a9 Mon Sep 17 00:00:00 2001 From: Neil Date: Thu, 15 Jul 2021 14:04:44 +1000 Subject: 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. --- src/CellBuffer.cxx | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/CellBuffer.cxx') 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 -- cgit v1.2.3