diff options
author | Zufu Liu <unknown> | 2023-11-21 11:40:02 +1100 |
---|---|---|
committer | Zufu Liu <unknown> | 2023-11-21 11:40:02 +1100 |
commit | 8a159b44bdf6541f7dcd640e160447617db13989 (patch) | |
tree | 56551bfb4f7f05272a2e813b7d1469d0eb56e540 | |
parent | df54de37b0a372a49bed0130406a5b75b85cd119 (diff) | |
download | scintilla-mirror-8a159b44bdf6541f7dcd640e160447617db13989.tar.gz |
Feature [feature-requests:#1502] Improve speed of LineLayoutCache::Invalidate
for replacing text.
-rw-r--r-- | doc/ScintillaHistory.html | 4 | ||||
-rw-r--r-- | src/PositionCache.cxx | 15 | ||||
-rw-r--r-- | src/PositionCache.h | 2 |
3 files changed, 12 insertions, 9 deletions
diff --git a/doc/ScintillaHistory.html b/doc/ScintillaHistory.html index 94b020036..333121b42 100644 --- a/doc/ScintillaHistory.html +++ b/doc/ScintillaHistory.html @@ -591,6 +591,10 @@ Released 18 November 2023. </li> <li> + Improve performance of global replace by reducing cache invalidation overhead. + <a href="https://sourceforge.net/p/scintilla/feature-requests/1502/">Feature #1502</a>. + </li> + <li> Fix regular expression search failure when search for "\<" followed by search for "\>". <a href="https://sourceforge.net/p/scintilla/bugs/2413/">Bug #2413</a>. </li> diff --git a/src/PositionCache.cxx b/src/PositionCache.cxx index 8c0e2046b..9cb617174 100644 --- a/src/PositionCache.cxx +++ b/src/PositionCache.cxx @@ -471,7 +471,7 @@ bool SignificantLines::LineMayCache(Sci::Line line) const noexcept { LineLayoutCache::LineLayoutCache() : level(LineCache::None), - allInvalidated(false), styleClock(-1) { + maxValidity(LineLayout::ValidLevel::invalid), styleClock(-1) { } LineLayoutCache::~LineLayoutCache() = default; @@ -520,7 +520,7 @@ void LineLayoutCache::AllocateForLevel(Sci::Line linesOnScreen, Sci::Line linesI } if (lengthForLevel != cache.size()) { - allInvalidated = false; + maxValidity = LineLayout::ValidLevel::lines; cache.resize(lengthForLevel); // Cache::none -> no entries // Cache::caret -> 1 entry can take any line @@ -563,26 +563,25 @@ void LineLayoutCache::AllocateForLevel(Sci::Line linesOnScreen, Sci::Line linesI } void LineLayoutCache::Deallocate() noexcept { + maxValidity = LineLayout::ValidLevel::invalid; cache.clear(); } void LineLayoutCache::Invalidate(LineLayout::ValidLevel validity_) noexcept { - if (!cache.empty() && !allInvalidated) { + if (maxValidity > validity_) { + maxValidity = validity_; for (const std::shared_ptr<LineLayout> &ll : cache) { if (ll) { ll->Invalidate(validity_); } } - if (validity_ == LineLayout::ValidLevel::invalid) { - allInvalidated = true; - } } } void LineLayoutCache::SetLevel(LineCache level_) noexcept { if (level != level_) { level = level_; - allInvalidated = false; + maxValidity = LineLayout::ValidLevel::invalid; cache.clear(); } } @@ -594,7 +593,7 @@ std::shared_ptr<LineLayout> LineLayoutCache::Retrieve(Sci::Line lineNumber, Sci: Invalidate(LineLayout::ValidLevel::checkTextAndStyle); styleClock = styleClock_; } - allInvalidated = false; + maxValidity = LineLayout::ValidLevel::lines; size_t pos = 0; if (level == LineCache::Page) { // If first entry is this line then just reuse it. diff --git a/src/PositionCache.h b/src/PositionCache.h index e610ac879..b63fb22fc 100644 --- a/src/PositionCache.h +++ b/src/PositionCache.h @@ -156,7 +156,7 @@ public: private: Scintilla::LineCache level; std::vector<std::shared_ptr<LineLayout>>cache; - bool allInvalidated; + LineLayout::ValidLevel maxValidity; int styleClock; size_t EntryForLine(Sci::Line line) const noexcept; void AllocateForLevel(Sci::Line linesOnScreen, Sci::Line linesInDoc); |