aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorZufu Liu <unknown>2024-12-01 09:04:00 +1100
committerZufu Liu <unknown>2024-12-01 09:04:00 +1100
commit5ad2dc6896e36aae02d14965f9a98c9778c2e2d1 (patch)
treec3a6057164ad35ecc5c5608d11de6e0980c0757d
parent7d69a0041a965406464f61b6ebb5da18a10d7c83 (diff)
downloadscintilla-mirror-5ad2dc6896e36aae02d14965f9a98c9778c2e2d1.tar.gz
Feature [feature-requests:#1535]. Improve performance of DBCS text by avoiding
calling LineStartPosition.
-rw-r--r--doc/ScintillaHistory.html4
-rw-r--r--src/Document.cxx23
2 files changed, 11 insertions, 16 deletions
diff --git a/doc/ScintillaHistory.html b/doc/ScintillaHistory.html
index b8fe778a7..84cbab7ad 100644
--- a/doc/ScintillaHistory.html
+++ b/doc/ScintillaHistory.html
@@ -603,6 +603,10 @@
<a href="https://sourceforge.net/p/scintilla/feature-requests/1533/">Feature #1533</a>.
</li>
<li>
+ Improve performance of DBCS text.
+ <a href="https://sourceforge.net/p/scintilla/feature-requests/1535/">Feature #1535</a>.
+ </li>
+ <li>
Fix wrapping removed lines.
<a href="https://sourceforge.net/p/scintilla/bugs/2456/">Bug #2456</a>.
</li>
diff --git a/src/Document.cxx b/src/Document.cxx
index 188ae658f..a601d48ce 100644
--- a/src/Document.cxx
+++ b/src/Document.cxx
@@ -833,15 +833,9 @@ Sci::Position Document::MovePositionOutsideChar(Sci::Position pos, Sci::Position
// Else invalid UTF-8 so return position of isolated trail byte
}
} else {
- // Anchor DBCS calculations at start of line because start of line can
- // not be a DBCS trail byte.
- const Sci::Position posStartLine = LineStartPosition(pos);
- if (pos == posStartLine)
- return pos;
-
// Step back until a non-lead-byte is found.
Sci::Position posCheck = pos;
- while ((posCheck > posStartLine) && IsDBCSLeadByteNoExcept(cb.CharAt(posCheck-1)))
+ while ((posCheck > 0) && IsDBCSLeadByteNoExcept(cb.CharAt(posCheck-1)))
posCheck--;
// Check from known start of character.
@@ -916,14 +910,11 @@ Sci::Position Document::NextPosition(Sci::Position pos, int moveDir) const noexc
if (pos > cb.Length())
pos = cb.Length();
} else {
- // Anchor DBCS calculations at start of line because start of line can
- // not be a DBCS trail byte.
- const Sci::Position posStartLine = LineStartPosition(pos);
- // See http://msdn.microsoft.com/en-us/library/cc194792%28v=MSDN.10%29.aspx
- // http://msdn.microsoft.com/en-us/library/cc194790.aspx
- if ((pos - 1) <= posStartLine) {
- return pos - 1;
- } else if (IsDBCSLeadByteNoExcept(cb.CharAt(pos - 1))) {
+ // How to Go Backward in a DBCS String
+ // https://msdn.microsoft.com/en-us/library/cc194792.aspx
+ // DBCS-Enabled Programs vs. Non-DBCS-Enabled Programs
+ // https://msdn.microsoft.com/en-us/library/cc194790.aspx
+ if (IsDBCSLeadByteNoExcept(cb.CharAt(pos - 1))) {
// Should actually be trail byte
if (IsDBCSDualByteAt(pos - 2)) {
return pos - 2;
@@ -934,7 +925,7 @@ Sci::Position Document::NextPosition(Sci::Position pos, int moveDir) const noexc
} else {
// Otherwise, step back until a non-lead-byte is found.
Sci::Position posTemp = pos - 1;
- while (posStartLine <= --posTemp && IsDBCSLeadByteNoExcept(cb.CharAt(posTemp)))
+ while (--posTemp >= 0 && IsDBCSLeadByteNoExcept(cb.CharAt(posTemp)))
;
// Now posTemp+1 must point to the beginning of a character,
// so figure out whether we went back an even or an odd