diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/PositionCache.cxx | 15 | ||||
-rw-r--r-- | src/PositionCache.h | 2 |
2 files changed, 8 insertions, 9 deletions
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); |