diff options
author | Zufu Liu <unknown> | 2021-07-12 10:14:12 +1000 |
---|---|---|
committer | Zufu Liu <unknown> | 2021-07-12 10:14:12 +1000 |
commit | 1c0b65457d35b23501060246292ad345b3e53147 (patch) | |
tree | 028c2048f96e5199a4889be00e5596c89f24eacb /src | |
parent | 39d0405bcdda80d73341e965aec175805771abb3 (diff) | |
download | scintilla-mirror-1c0b65457d35b23501060246292ad345b3e53147.tar.gz |
Feature [feature-requests:#1381] Optimize case sensitive search.
Diffstat (limited to 'src')
-rw-r--r-- | src/Document.cxx | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/Document.cxx b/src/Document.cxx index c8e1ff701..8db6e2efa 100644 --- a/src/Document.cxx +++ b/src/Document.cxx @@ -2007,9 +2007,10 @@ Sci::Position Document::FindText(Sci::Position minPos, Sci::Position maxPos, con } if (caseSensitive) { const Sci::Position endSearch = (startPos <= endPos) ? endPos - lengthFind + 1 : endPos; - const char charStartSearch = search[0]; + const unsigned char charStartSearch = search[0]; while (forward ? (pos < endSearch) : (pos >= endSearch)) { - if (CharAt(pos) == charStartSearch) { + const unsigned char leadByte = cb.UCharAt(pos); + if (leadByte == charStartSearch) { bool found = (pos + lengthFind) <= limitPos; for (int indexSearch = 1; (indexSearch < lengthFind) && found; indexSearch++) { found = CharAt(pos + indexSearch) == search[indexSearch]; @@ -2018,8 +2019,16 @@ Sci::Position Document::FindText(Sci::Position minPos, Sci::Position maxPos, con return pos; } } - if (!NextCharacter(pos, increment)) - break; + if (forward && UTF8IsAscii(leadByte)) { + pos++; + } else { + if (dbcsCodePage) { + if (!NextCharacter(pos, increment)) + break; + } else { + pos += increment; + } + } } } else if (CpUtf8 == dbcsCodePage) { constexpr size_t maxFoldingExpansion = 4; |