From 4e556e4aaba49f4307ab4933a376e0c34d0be674 Mon Sep 17 00:00:00 2001 From: Neil Date: Sun, 1 May 2022 14:31:17 +1000 Subject: Optimize case where there are no annotations --- src/Document.cxx | 6 ++++++ src/PerLine.cxx | 4 ++++ src/PerLine.h | 2 ++ 3 files changed, 12 insertions(+) (limited to 'src') 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; lEmpty()) { + return; + } const Sci::Line maxEditorLine = LinesTotal(); for (Sci::Line l=0; lAllocateAnnotation(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; -- cgit v1.2.3