diff options
author | Zufu Liu <unknown> | 2021-07-16 08:53:43 +1000 |
---|---|---|
committer | Zufu Liu <unknown> | 2021-07-16 08:53:43 +1000 |
commit | 7acc601f5818a46837baff31ccc231d1cc4b1ffe (patch) | |
tree | e0ec885f5543ebd652d0d291d2cf070010b9cc26 /src/Document.cxx | |
parent | 65ea703cfbf8d5660c59e8b1ab756ed7ddde50a9 (diff) | |
download | scintilla-mirror-7acc601f5818a46837baff31ccc231d1cc4b1ffe.tar.gz |
Feature [feature-requests:#1381] Avoid strlen and more complex comparison.
Diffstat (limited to 'src/Document.cxx')
-rw-r--r-- | src/Document.cxx | 6 |
1 files changed, 3 insertions, 3 deletions
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)) { |