aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorZufu Liu <unknown>2025-05-25 10:14:33 +1000
committerZufu Liu <unknown>2025-05-25 10:14:33 +1000
commit12f6ca53a028a72028b345e6fb3d181c47b66105 (patch)
tree18ec874ee6fc91c4bce1fd7c5a3be2c149f3c040
parentaca9ce76597949b0429caa882df164702cdb92b0 (diff)
downloadscintilla-mirror-12f6ca53a028a72028b345e6fb3d181c47b66105.tar.gz
Feature [feature-requests:#1557]. Simplify LineLayout deallocation.
-rw-r--r--src/PositionCache.cxx21
-rw-r--r--src/PositionCache.h7
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<char[]>(lineAllocation);
styles = std::make_unique<unsigned char []>(lineAllocation);
// Extra position allocated as sometimes the Windows
// GetTextExtentExPoint API writes an extra element.
positions = std::make_unique<XYPOSITION []>(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;