From d8b5fc5dd9542e011974803ae5bdc0190baed774 Mon Sep 17 00:00:00 2001 From: Zufu Liu Date: Sat, 23 Mar 2024 09:08:06 +1100 Subject: Feature [feature-requests:#1512]. Simplify ScaledVector::PushBack. Prefer UndoActions::Length to UndoActions::lengths.ValueAt. --- src/UndoHistory.cxx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/UndoHistory.cxx b/src/UndoHistory.cxx index 929c8743e..c4b241103 100644 --- a/src/UndoHistory.cxx +++ b/src/UndoHistory.cxx @@ -120,7 +120,7 @@ void ScaledVector::ReSize(size_t length) { } void ScaledVector::PushBack() { - ReSize(Size() + 1); + bytes.resize(bytes.size() + element.size); } size_t ScaledVector::SizeInBytes() const noexcept { @@ -496,9 +496,9 @@ std::string_view UndoHistory::Text(int action) noexcept { position = memory->position; } for (; act < action; act++) { - position += actions.lengths.ValueAt(act); + position += actions.Length(act); } - const size_t length = actions.lengths.ValueAt(action); + const size_t length = actions.Length(action); const char *scrap = scraps->TextAt(position); memory = {action, position}; return {scrap, length}; @@ -581,7 +581,7 @@ Action UndoHistory::GetUndoStep() const noexcept { } void UndoHistory::CompletedUndoStep() noexcept { - scraps->MoveBack(actions.lengths.ValueAt(PreviousAction())); + scraps->MoveBack(actions.Length(PreviousAction())); currentAction--; } @@ -624,7 +624,7 @@ Action UndoHistory::GetRedoStep() const noexcept { } void UndoHistory::CompletedRedoStep() noexcept { - scraps->MoveForward(actions.lengths.ValueAt(currentAction)); + scraps->MoveForward(actions.Length(currentAction)); currentAction++; } -- cgit v1.2.3