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/Document.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/Document.cxx')
-rw-r--r-- | src/Document.cxx | 34 |
1 files changed, 1 insertions, 33 deletions
diff --git a/src/Document.cxx b/src/Document.cxx index e0fd78eda..45e0799e8 100644 --- a/src/Document.cxx +++ b/src/Document.cxx @@ -1986,38 +1986,6 @@ Document::CharacterExtracted Document::ExtractCharacter(Sci::Position position) namespace { -struct SplitView { - const char *segment1 = nullptr; - size_t length1 = 0; - const char *segment2 = nullptr; - size_t length = 0; - - SplitView() = default; - SplitView(CellBuffer &cb) noexcept { - segment1 = cb.RangePointer(0, 0); - length1 = cb.GapPosition(); - segment2 = cb.RangePointer(length1, 0) - length1; - length = cb.Length(); - } - bool operator==(const SplitView &other) const noexcept { - return segment1 == other.segment1 && length1 == other.length1 && - segment2 == other.segment2 && length == other.length; - } - bool operator!=(const SplitView &other) const noexcept { - return !(*this == other); - } - - char CharAt(size_t position) const noexcept { - if (position < length1) { - return segment1[position]; - } - if (position < length) { - return segment2[position]; - } - return 0; - } -}; - // Equivalent of memchr over the split view ptrdiff_t SplitFindChar(const SplitView &view, size_t start, size_t length, int ch) noexcept { size_t range1Length = 0; @@ -2086,7 +2054,7 @@ Sci::Position Document::FindText(Sci::Position minPos, Sci::Position maxPos, con // Back all of a character pos = NextPosition(pos, increment); } - const SplitView cbView(cb); + const SplitView cbView = cb.AllView(); if (caseSensitive) { const Sci::Position endSearch = (startPos <= endPos) ? endPos - lengthFind + 1 : endPos; const unsigned char charStartSearch = search[0]; |