aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/PositionCache.cxx
diff options
context:
space:
mode:
authorZufu Liu <unknown>2021-10-21 22:19:57 +1100
committerZufu Liu <unknown>2021-10-21 22:19:57 +1100
commit352fc86fe34bf8c5d0570e0e1dd3b568fcfcefe1 (patch)
tree2ae6a9a478f360371141e8f5e4848a720cbd08b7 /src/PositionCache.cxx
parent9975609bf3b39f0e1cd121995ac49aea30a6c48f (diff)
downloadscintilla-mirror-352fc86fe34bf8c5d0570e0e1dd3b568fcfcefe1.tar.gz
Feature [feature-requests:#1417] Simplify BreakFinder::Next.
Diffstat (limited to 'src/PositionCache.cxx')
-rw-r--r--src/PositionCache.cxx17
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;
}