aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorZufu Liu <unknown>2024-11-17 08:32:07 +1100
committerZufu Liu <unknown>2024-11-17 08:32:07 +1100
commit7c053368aac18001e6183c1f2e72273631cb5100 (patch)
tree2ff77937483c438a8e0c6b898afe167d0f2536a5
parente70b850241c81eae9ab2f7c2aa75b06634c96f1e (diff)
downloadscintilla-mirror-7c053368aac18001e6183c1f2e72273631cb5100.tar.gz
Feature [feature-requests:#1533]. Improve performance of SCI_BRACEMATCH by only
retrieving style for braces. Approximately 25% improvement on tested system.
-rw-r--r--doc/ScintillaHistory.html4
-rw-r--r--src/Document.cxx14
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 @@
<a href="https://github.com/ScintillaOrg/lexilla/issues/285">Issue #285</a>.
</li>
<li>
+ Improve performance of SCI_BRACEMATCH.
+ <a href="https://sourceforge.net/p/scintilla/feature-requests/1533/">Feature #1533</a>.
+ </li>
+ <li>
On GTK, allow middle click to insert multiple times within a document.
<a href="https://github.com/geany/geany/issues/2629">Geany Issue #2629</a>.
</li>
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);