From f0d7f6fbc880ed1b5db8fc9fc52bc7cd99d209a6 Mon Sep 17 00:00:00 2001 From: Zufu Liu Date: Thu, 30 Sep 2021 14:27:52 +1000 Subject: Feature [feature-requests:#1416] Remove extra check that is never true and remove parameter used just for this test. --- src/Document.cxx | 4 +--- src/Document.h | 2 +- src/PositionCache.cxx | 2 +- 3 files changed, 3 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/Document.cxx b/src/Document.cxx index 8baa84ad8..eae055dc2 100644 --- a/src/Document.cxx +++ b/src/Document.cxx @@ -1142,9 +1142,7 @@ static constexpr bool IsSpaceOrTab(int ch) noexcept { // 2) Break before punctuation // 3) Break after whole character -int Document::SafeSegment(const char *text, int length, int lengthSegment) const noexcept { - if (length <= lengthSegment) - return length; +int Document::SafeSegment(const char *text, int lengthSegment) const noexcept { int lastSpaceBreak = -1; int lastPunctuationBreak = -1; int lastEncodingAllowedBreak = 0; diff --git a/src/Document.h b/src/Document.h index 402f37c17..897a1270c 100644 --- a/src/Document.h +++ b/src/Document.h @@ -352,7 +352,7 @@ public: bool IsDBCSTrailByteNoExcept(char ch) const noexcept; int DBCSDrawBytes(std::string_view text) const noexcept; bool IsDBCSDualByteAt(Sci::Position pos) const noexcept; - int SafeSegment(const char *text, int length, int lengthSegment) const noexcept; + int SafeSegment(const char *text, int lengthSegment) const noexcept; EncodingFamily CodePageFamily() const noexcept; // Gateways to modifying document diff --git a/src/PositionCache.cxx b/src/PositionCache.cxx index 6eee26113..63e130429 100644 --- a/src/PositionCache.cxx +++ b/src/PositionCache.cxx @@ -773,7 +773,7 @@ TextSegment BreakFinder::Next() { subBreak = -1; return TextSegment(startSegment, nextBreak - startSegment); } else { - subBreak += pdoc->SafeSegment(&ll->chars[subBreak], nextBreak-subBreak, lengthEachSubdivision); + subBreak += pdoc->SafeSegment(&ll->chars[subBreak], lengthEachSubdivision); if (subBreak >= nextBreak) { subBreak = -1; return TextSegment(startSegment, nextBreak - startSegment); -- cgit v1.2.3