aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/PerLine.cxx
diff options
context:
space:
mode:
authorZufu Liu <unknown>2022-07-17 14:09:52 +1000
committerZufu Liu <unknown>2022-07-17 14:09:52 +1000
commitf6a9859562ddeb04e882e4a3d15adbf64345452a (patch)
treef814dc8f40ea08c5d01d110ffb69a491806eea36 /src/PerLine.cxx
parent4e0683e5531aa99958fc742476b6150ec2595c72 (diff)
downloadscintilla-mirror-f6a9859562ddeb04e882e4a3d15adbf64345452a.tar.gz
Feature [feature-requests:#1441] Line state optimized to avoid excess allocations
by always allocating for every line.
Diffstat (limited to 'src/PerLine.cxx')
-rw-r--r--src/PerLine.cxx17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/PerLine.cxx b/src/PerLine.cxx
index 2ea3f0ce4..f3fddcf27 100644
--- a/src/PerLine.cxx
+++ b/src/PerLine.cxx
@@ -262,15 +262,13 @@ void LineLevels::ClearLevels() {
}
int LineLevels::SetLevel(Sci::Line line, int level, Sci::Line lines) {
- int prev = 0;
+ int prev = level;
if ((line >= 0) && (line < lines)) {
if (!levels.Length()) {
ExpandLevels(lines + 1);
}
prev = levels[line];
- if (prev != level) {
- levels[line] = level;
- }
+ levels[line] = level;
}
return prev;
}
@@ -312,10 +310,13 @@ void LineState::RemoveLine(Sci::Line line) {
}
}
-int LineState::SetLineState(Sci::Line line, int state) {
- lineStates.EnsureLength(line + 1);
- const int stateOld = lineStates[line];
- lineStates[line] = state;
+int LineState::SetLineState(Sci::Line line, int state, Sci::Line lines) {
+ int stateOld = state;
+ if ((line >= 0) && (line < lines)) {
+ lineStates.EnsureLength(lines + 1);
+ stateOld = lineStates[line];
+ lineStates[line] = state;
+ }
return stateOld;
}