From 2d69e7321020afde6fb8c45943c5d59781461e6b Mon Sep 17 00:00:00 2001 From: Neil Date: Thu, 1 Feb 2024 16:37:24 +1100 Subject: Prefer member initializers. Simplify logic. --- src/UndoHistory.cxx | 10 +--------- src/UndoHistory.h | 10 +++++----- 2 files changed, 6 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/UndoHistory.cxx b/src/UndoHistory.cxx index bc1a4d36a..88e931ea9 100644 --- a/src/UndoHistory.cxx +++ b/src/UndoHistory.cxx @@ -101,15 +101,8 @@ const char *ScrapStack::TextAt(size_t position) const noexcept { // Sequences that look like typing or deletion are coalesced into a single user operation. UndoHistory::UndoHistory() { - actions.resize(3); - maxAction = 0; - currentAction = 0; - undoSequenceDepth = 0; - savePoint = 0; - tentativePoint = -1; scraps = std::make_unique(); - actions[currentAction].Create(ActionType::start); } @@ -287,8 +280,7 @@ int UndoHistory::TentativeSteps() noexcept { currentAction--; if (tentativePoint >= 0) return currentAction - tentativePoint; - else - return -1; + return -1; } bool UndoHistory::CanUndo() const noexcept { diff --git a/src/UndoHistory.h b/src/UndoHistory.h index 98df93465..349ca2665 100644 --- a/src/UndoHistory.h +++ b/src/UndoHistory.h @@ -39,11 +39,11 @@ public: */ class UndoHistory { std::vector actions; - int maxAction; - int currentAction; - int undoSequenceDepth; - int savePoint; - int tentativePoint; + int maxAction = 0; + int currentAction = 0; + int undoSequenceDepth = 0; + int savePoint = 0; + int tentativePoint = -1; std::optional detach; std::unique_ptr scraps; -- cgit v1.2.3