diff options
author | Neil <nyamatongwe@gmail.com> | 2024-02-01 17:17:44 +1100 |
---|---|---|
committer | Neil <nyamatongwe@gmail.com> | 2024-02-01 17:17:44 +1100 |
commit | 687046150ab6d5fc7b0dce1392e0a60ebb6acb6f (patch) | |
tree | 2648332517a051eb45e6960fbf06029198c5c084 /src/UndoHistory.h | |
parent | 2d69e7321020afde6fb8c45943c5d59781461e6b (diff) | |
download | scintilla-mirror-687046150ab6d5fc7b0dce1392e0a60ebb6acb6f.tar.gz |
Change UndoHistory from an array-of-structs to a struct-of-arrays to allow each
element to use minimum memory. Start by reducing (type,mayCoalesce) from 8 or 4
bytes to 1 byte.
Diffstat (limited to 'src/UndoHistory.h')
-rw-r--r-- | src/UndoHistory.h | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/src/UndoHistory.h b/src/UndoHistory.h index 349ca2665..8975b4362 100644 --- a/src/UndoHistory.h +++ b/src/UndoHistory.h @@ -10,16 +10,21 @@ namespace Scintilla::Internal { -class UndoAction { +class UndoActionType { public: - ActionType at = ActionType::insert; - bool mayCoalesce = false; - Sci::Position position = 0; - Sci::Position lenData = 0; - - UndoAction() noexcept; - void Create(ActionType at_, Sci::Position position_=0, Sci::Position lenData_=0, bool mayCoalesce_=true) noexcept; - void Clear() noexcept; + ActionType at : 4; + bool mayCoalesce : 1; + UndoActionType() noexcept; +}; + +struct UndoActions { + std::vector<UndoActionType> types; + std::vector<Sci::Position> positions; + std::vector<Sci::Position> lengths; + + void resize(size_t length); + [[nodiscard]] size_t size() const noexcept; + void Create(size_t index, ActionType at_, Sci::Position position_ = 0, Sci::Position lenData_ = 0, bool mayCoalesce_ = true) noexcept; }; class ScrapStack { @@ -38,7 +43,7 @@ public: * */ class UndoHistory { - std::vector<UndoAction> actions; + UndoActions actions; int maxAction = 0; int currentAction = 0; int undoSequenceDepth = 0; |