From 7c053368aac18001e6183c1f2e72273631cb5100 Mon Sep 17 00:00:00 2001 From: Zufu Liu Date: Sun, 17 Nov 2024 08:32:07 +1100 Subject: Feature [feature-requests:#1533]. Improve performance of SCI_BRACEMATCH by only retrieving style for braces. Approximately 25% improvement on tested system. --- doc/ScintillaHistory.html | 4 ++++ src/Document.cxx | 14 ++++++-------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/doc/ScintillaHistory.html b/doc/ScintillaHistory.html index dc3a0278e..2f1a4dfcb 100644 --- a/doc/ScintillaHistory.html +++ b/doc/ScintillaHistory.html @@ -597,6 +597,10 @@ Issue #285.
  • + Improve performance of SCI_BRACEMATCH. + Feature #1533. +
  • +
  • On GTK, allow middle click to insert multiple times within a document. Geany Issue #2629.
  • diff --git a/src/Document.cxx b/src/Document.cxx index 4b1f76a2a..ef8bfce4d 100644 --- a/src/Document.cxx +++ b/src/Document.cxx @@ -2840,14 +2840,12 @@ Sci::Position Document::BraceMatch(Sci::Position position, Sci::Position /*maxRe position = useStartPos ? startPos : NextPosition(position, direction); while ((position >= 0) && (position < LengthNoExcept())) { const char chAtPos = CharAt(position); - const int styAtPos = StyleIndexAt(position); - if ((position > GetEndStyled()) || (styAtPos == styBrace)) { - if (chAtPos == chBrace) - depth++; - if (chAtPos == chSeek) - depth--; - if (depth == 0) - return position; + if (chAtPos == chBrace || chAtPos == chSeek) { + if ((position > GetEndStyled()) || (StyleIndexAt(position) == styBrace)) { + depth += (chAtPos == chBrace) ? 1 : -1; + if (depth == 0) + return position; + } } const Sci::Position positionBeforeMove = position; position = NextPosition(position, direction); -- cgit v1.2.3