From 7acc601f5818a46837baff31ccc231d1cc4b1ffe Mon Sep 17 00:00:00 2001 From: Zufu Liu Date: Fri, 16 Jul 2021 08:53:43 +1000 Subject: Feature [feature-requests:#1381] Avoid strlen and more complex comparison. --- src/Document.cxx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/Document.cxx b/src/Document.cxx index 45e0799e8..b39779c54 100644 --- a/src/Document.cxx +++ b/src/Document.cxx @@ -2001,7 +2001,7 @@ ptrdiff_t SplitFindChar(const SplitView &view, size_t start, size_t length, int if (match2) { return match2 - view.segment2 + view.length1; } - return PTRDIFF_MAX; + return -1; } // Equivalent of memcmp over the split view @@ -2062,10 +2062,10 @@ Sci::Position Document::FindText(Sci::Position minPos, Sci::Position maxPos, con // This is a fast case where there is no need to test byte values to iterate // so becomes the equivalent of a memchr+memcmp loop. // UTF-8 search will not be self-synchronizing when starts with trail byte - const std::string_view suffix = search + 1; + const std::string_view suffix(search + 1, lengthFind - 1); while (pos < endSearch) { pos = SplitFindChar(cbView, pos, limitPos - pos, charStartSearch); - if (pos == PTRDIFF_MAX) { + if (pos < 0) { break; } if (SplitMatch(cbView, pos + 1, suffix) && MatchesWordOptions(word, wordStart, pos, lengthFind)) { -- cgit v1.2.3