aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorZufu Liu <unknown>2024-12-01 09:15:15 +1100
committerZufu Liu <unknown>2024-12-01 09:15:15 +1100
commitd7aa275894ce878d5d8b62acd3deba608e8a5b75 (patch)
tree5cc2a908af69a97d526bb0635396e1f752468e12
parent5ad2dc6896e36aae02d14965f9a98c9778c2e2d1 (diff)
downloadscintilla-mirror-d7aa275894ce878d5d8b62acd3deba608e8a5b75.tar.gz
Feature [feature-requests:#1535]. Improve performance of DBCS brace matching.
-rw-r--r--src/Document.cxx16
1 files changed, 5 insertions, 11 deletions
diff --git a/src/Document.cxx b/src/Document.cxx
index a601d48ce..41a1c3414 100644
--- a/src/Document.cxx
+++ b/src/Document.cxx
@@ -2854,29 +2854,23 @@ Sci::Position Document::BraceMatch(Sci::Position position, Sci::Position /*maxRe
int depth = 1;
position = useStartPos ? startPos : NextPosition(position, direction);
- // Avoid complex NextPosition call for bytes that may not cause incorrect match
+ // Avoid using MovePositionOutsideChar to check DBCS trail byte
unsigned char maxSafeChar = 0xff;
if (dbcsCodePage != 0 && dbcsCodePage != CpUtf8) {
- maxSafeChar = (direction >= 0) ? 0x80 : DBCSMinTrailByte() - 1;
+ maxSafeChar = DBCSMinTrailByte() - 1;
}
while ((position >= 0) && (position < LengthNoExcept())) {
const unsigned char chAtPos = CharAt(position);
if (chAtPos == chBrace || chAtPos == chSeek) {
- if ((position > GetEndStyled()) || (StyleIndexAt(position) == styBrace)) {
+ if (((position > GetEndStyled()) || (StyleIndexAt(position) == styBrace)) &&
+ (chAtPos <= maxSafeChar || position == MovePositionOutsideChar(position, direction, false))) {
depth += (chAtPos == chBrace) ? 1 : -1;
if (depth == 0)
return position;
}
}
- if (chAtPos <= maxSafeChar) {
- position += direction;
- } else {
- const Sci::Position positionBeforeMove = position;
- position = NextPosition(position, direction);
- if (position == positionBeforeMove)
- break;
- }
+ position += direction;
}
return - 1;
}