From 7e32149ab735019ad029c0559b99998b2d525053 Mon Sep 17 00:00:00 2001 From: Zufu Liu Date: Sat, 27 Jan 2024 19:51:31 +1100 Subject: Feature [feature-requests:#1458] Reduce memory used for undo actions. --- doc/ScintillaHistory.html | 4 ++++ src/CellBuffer.cxx | 13 ++++--------- src/CellBuffer.h | 10 +++++----- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/doc/ScintillaHistory.html b/doc/ScintillaHistory.html index 67f26fb3d..9b842e278 100644 --- a/doc/ScintillaHistory.html +++ b/doc/ScintillaHistory.html @@ -591,6 +591,10 @@ Released 27 December 2023.
  • + Reduce memory used for undo actions. + Feature #1458. +
  • +
  • For ScintillaEdit on Qt, fix reference from ScintillaDocument to Document to match change in 5.4.1 using IDocumentEditable for SCI_GETDOCPOINTER and SCI_SETDOCPOINTER.
  • diff --git a/src/CellBuffer.cxx b/src/CellBuffer.cxx index 32cc9d730..575aae584 100644 --- a/src/CellBuffer.cxx +++ b/src/CellBuffer.cxx @@ -329,23 +329,18 @@ public: } }; -Action::Action() noexcept { - at = ActionType::start; - position = 0; - lenData = 0; - mayCoalesce = false; -} +Action::Action() noexcept = default; void Action::Create(ActionType at_, Sci::Position position_, const char *data_, Sci::Position lenData_, bool mayCoalesce_) { - data = nullptr; position = position_; at = at_; + mayCoalesce = mayCoalesce_; + lenData = lenData_; + data = nullptr; if (lenData_) { data = std::make_unique(lenData_); memcpy(&data[0], data_, lenData_); } - lenData = lenData_; - mayCoalesce = mayCoalesce_; } void Action::Clear() noexcept { diff --git a/src/CellBuffer.h b/src/CellBuffer.h index f0aacf8ec..b46b582c1 100644 --- a/src/CellBuffer.h +++ b/src/CellBuffer.h @@ -26,18 +26,18 @@ class ChangeHistory; */ class ILineVector; -enum class ActionType { insert, remove, start, container }; +enum class ActionType : unsigned char { insert, remove, start, container }; /** * Actions are used to store all the information required to perform one undo/redo step. */ class Action { public: - ActionType at; - Sci::Position position; + ActionType at = ActionType::insert; + bool mayCoalesce = false; + Sci::Position position = 0; std::unique_ptr data; - Sci::Position lenData; - bool mayCoalesce; + Sci::Position lenData = 0; Action() noexcept; void Create(ActionType at_, Sci::Position position_=0, const char *data_=nullptr, Sci::Position lenData_=0, bool mayCoalesce_=true); -- cgit v1.2.3