aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorNeil <nyamatongwe@gmail.com>2022-05-01 14:31:17 +1000
committerNeil <nyamatongwe@gmail.com>2022-05-01 14:31:17 +1000
commit4e556e4aaba49f4307ab4933a376e0c34d0be674 (patch)
tree9b708589b2163edc5ff26fd2c5f3a2a95dbad335 /src
parent528eca1cf29f8e02afd3cb51724c2fe2eed69894 (diff)
downloadscintilla-mirror-4e556e4aaba49f4307ab4933a376e0c34d0be674.tar.gz
Optimize case where there are no annotations
Diffstat (limited to 'src')
-rw-r--r--src/Document.cxx6
-rw-r--r--src/PerLine.cxx4
-rw-r--r--src/PerLine.h2
3 files changed, 12 insertions, 0 deletions
diff --git a/src/Document.cxx b/src/Document.cxx
index 69eec5254..54d14cda3 100644
--- a/src/Document.cxx
+++ b/src/Document.cxx
@@ -2518,6 +2518,9 @@ int Document::AnnotationLines(Sci::Line line) const noexcept {
}
void Document::AnnotationClearAll() {
+ if (Annotations()->Empty()) {
+ return;
+ }
const Sci::Line maxEditorLine = LinesTotal();
for (Sci::Line l=0; l<maxEditorLine; l++)
AnnotationSetText(l, nullptr);
@@ -2550,6 +2553,9 @@ void Document::EOLAnnotationSetStyle(Sci::Line line, int style) {
}
void Document::EOLAnnotationClearAll() {
+ if (EOLAnnotations()->Empty()) {
+ return;
+ }
const Sci::Line maxEditorLine = LinesTotal();
for (Sci::Line l=0; l<maxEditorLine; l++)
EOLAnnotationSetText(l, nullptr);
diff --git a/src/PerLine.cxx b/src/PerLine.cxx
index 762891ee3..2ea3f0ce4 100644
--- a/src/PerLine.cxx
+++ b/src/PerLine.cxx
@@ -357,6 +357,10 @@ std::unique_ptr<char[]>AllocateAnnotation(size_t length, int style) {
LineAnnotation::~LineAnnotation() {
}
+bool LineAnnotation::Empty() const noexcept {
+ return annotations.Length() == 0;
+}
+
void LineAnnotation::Init() {
ClearAll();
}
diff --git a/src/PerLine.h b/src/PerLine.h
index 8f88183f1..3f7defa3c 100644
--- a/src/PerLine.h
+++ b/src/PerLine.h
@@ -127,6 +127,8 @@ public:
void operator=(const LineAnnotation &) = delete;
void operator=(LineAnnotation &&) = delete;
~LineAnnotation() override;
+
+ [[nodiscard]] bool Empty() const noexcept;
void Init() override;
void InsertLine(Sci::Line line) override;
void InsertLines(Sci::Line line, Sci::Line lines) override;