diff options
author | Zufu Liu <unknown> | 2021-10-21 22:19:57 +1100 |
---|---|---|
committer | Zufu Liu <unknown> | 2021-10-21 22:19:57 +1100 |
commit | 352fc86fe34bf8c5d0570e0e1dd3b568fcfcefe1 (patch) | |
tree | 2ae6a9a478f360371141e8f5e4848a720cbd08b7 | |
parent | 9975609bf3b39f0e1cd121995ac49aea30a6c48f (diff) | |
download | scintilla-mirror-352fc86fe34bf8c5d0570e0e1dd3b568fcfcefe1.tar.gz |
Feature [feature-requests:#1417] Simplify BreakFinder::Next.
-rw-r--r-- | src/PositionCache.cxx | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/src/PositionCache.cxx b/src/PositionCache.cxx index c9f4e8793..bf46a552b 100644 --- a/src/PositionCache.cxx +++ b/src/PositionCache.cxx @@ -706,8 +706,9 @@ BreakFinder::BreakFinder(const LineLayout *ll_, const Selection *psel, Range lin BreakFinder::~BreakFinder() noexcept = default; TextSegment BreakFinder::Next() { - if (subBreak == -1) { + if (subBreak < 0) { const int prev = nextBreak; + const Representation *repr = nullptr; while (nextBreak < lineRange.end) { int charWidth = 1; const char * const chars = &ll->chars[nextBreak]; @@ -719,7 +720,7 @@ TextSegment BreakFinder::Next() { charWidth = pdoc->DBCSDrawBytes(std::string_view(chars, lineRange.end - nextBreak)); } } - const Representation *repr = nullptr; + repr = nullptr; if (preprs->MayContain(ch)) { // Special case \r\n line ends if there is a representation if (ch == '\r' && preprs->ContainsCrLf() && chars[1] == '\n') { @@ -741,17 +742,15 @@ TextSegment BreakFinder::Next() { } else { repr = nullptr; // Optimize -> should remember repr } - if ((nextBreak - prev) < lengthStartSubdivision) { - return TextSegment(prev, nextBreak - prev, repr); - } else { - break; - } + break; } } nextBreak += charWidth; } - if ((nextBreak - prev) < lengthStartSubdivision) { - return TextSegment(prev, nextBreak - prev); + + const int lengthSegment = nextBreak - prev; + if (lengthSegment < lengthStartSubdivision) { + return TextSegment(prev, lengthSegment, repr); } subBreak = prev; } |