aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Document.cxx
diff options
context:
space:
mode:
authorNeil <nyamatongwe@gmail.com>2026-03-30 18:30:55 +1100
committerNeil <nyamatongwe@gmail.com>2026-03-30 18:30:55 +1100
commitf07caccbf33acd188cbe4961ece30251102351cc (patch)
tree9a7b573d41923b77229e28386164d05e9d710fff /src/Document.cxx
parenta00464fbff54f486efa3ee103948e3526548fc46 (diff)
downloadscintilla-mirror-f07caccbf33acd188cbe4961ece30251102351cc.tar.gz
Feature [feature-requests:#1582]. Improve performance of Document::SetStyles.
Report changed range for Document::SetStyleFor.
Diffstat (limited to 'src/Document.cxx')
-rw-r--r--src/Document.cxx25
1 files changed, 7 insertions, 18 deletions
diff --git a/src/Document.cxx b/src/Document.cxx
index ab4da0179..d4754233e 100644
--- a/src/Document.cxx
+++ b/src/Document.cxx
@@ -2571,10 +2571,10 @@ bool SCI_METHOD Document::SetStyleFor(Sci_Position length, char style) {
return false;
}
enteredStyling++;
- const Sci::Position prevEndStyled = endStyled;
- if (cb.SetStyleFor(endStyled, length, style)) {
+ const ChangedRange cr = cb.SetStyleFor(endStyled, length, style);
+ if (!cr.Empty()) {
const DocModification mh(ModificationFlags::ChangeStyle | ModificationFlags::User,
- prevEndStyled, length);
+ cr.start, cr.end - cr.start + 1);
NotifyModified(mh);
}
endStyled += length;
@@ -2587,22 +2587,11 @@ bool SCI_METHOD Document::SetStyles(Sci_Position length, const char *styles) {
return false;
}
enteredStyling++;
- bool didChange = false;
- Sci::Position startMod = 0;
- Sci::Position endMod = 0;
- for (int iPos = 0; iPos < length; iPos++, endStyled++) {
- PLATFORM_ASSERT(endStyled < Length());
- if (cb.SetStyleAt(endStyled, styles[iPos])) {
- if (!didChange) {
- startMod = endStyled;
- }
- didChange = true;
- endMod = endStyled;
- }
- }
- if (didChange) {
+ const ChangedRange cr = cb.SetStyles(endStyled, styles, length);
+ endStyled += length;
+ if (!cr.Empty()) {
const DocModification mh(ModificationFlags::ChangeStyle | ModificationFlags::User,
- startMod, endMod - startMod + 1);
+ cr.start, cr.end - cr.start + 1);
NotifyModified(mh);
}
enteredStyling--;