From 12f6ca53a028a72028b345e6fb3d181c47b66105 Mon Sep 17 00:00:00 2001 From: Zufu Liu Date: Sun, 25 May 2025 10:14:33 +1000 Subject: Feature [feature-requests:#1557]. Simplify LineLayout deallocation. --- src/PositionCache.cxx | 21 +++------------------ src/PositionCache.h | 7 ------- 2 files changed, 3 insertions(+), 25 deletions(-) diff --git a/src/PositionCache.cxx b/src/PositionCache.cxx index ed3a08270..1f3a803fc 100644 --- a/src/PositionCache.cxx +++ b/src/PositionCache.cxx @@ -81,23 +81,17 @@ LineLayout::LineLayout(Sci::Line lineNumber_, int maxLineLength_) : Resize(maxLineLength_); } -LineLayout::~LineLayout() { - Free(); -} - void LineLayout::Resize(int maxLineLength_) { if (maxLineLength_ > maxLineLength) { - Free(); const size_t lineAllocation = maxLineLength_ + 1; chars = std::make_unique(lineAllocation); styles = std::make_unique(lineAllocation); // Extra position allocated as sometimes the Windows // GetTextExtentExPoint API writes an extra element. positions = std::make_unique(lineAllocation + 1); - if (bidiData) { - bidiData->Resize(maxLineLength_); - } - + lineStarts.reset(); + bidiData.reset(); + lenLineStarts = 0; maxLineLength = maxLineLength_; } } @@ -116,15 +110,6 @@ void LineLayout::EnsureBidiData() { } } -void LineLayout::Free() noexcept { - chars.reset(); - styles.reset(); - positions.reset(); - lineStarts.reset(); - lenLineStarts = 0; - bidiData.reset(); -} - void LineLayout::ClearPositions() { std::fill(&positions[0], &positions[maxLineLength + 2], 0.0f); } diff --git a/src/PositionCache.h b/src/PositionCache.h index 4b35ec092..b912c2fcc 100644 --- a/src/PositionCache.h +++ b/src/PositionCache.h @@ -76,16 +76,9 @@ public: XYPOSITION wrapIndent; // In pixels LineLayout(Sci::Line lineNumber_, int maxLineLength_); - // Deleted so LineLayout objects can not be copied. - LineLayout(const LineLayout &) = delete; - LineLayout(LineLayout &&) = delete; - void operator=(const LineLayout &) = delete; - void operator=(LineLayout &&) = delete; - virtual ~LineLayout(); void Resize(int maxLineLength_); void ReSet(Sci::Line lineNumber_, Sci::Position maxLineLength_); void EnsureBidiData(); - void Free() noexcept; void ClearPositions(); void Invalidate(ValidLevel validity_) noexcept; Sci::Line LineNumber() const noexcept; -- cgit v1.2.3