summaryrefslogtreecommitdiff
path: root/svl
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2021-11-15 09:41:23 +0100
committerMiklos Vajna <vmiklos@collabora.com>2021-11-15 11:39:56 +0100
commit2a8506c2f20f18c948fb4dc5beb42b1010ad6999 (patch)
treebef563ee28b8811a31f2e38ba5857fc387e9311d /svl
parentc858a59158ed638642139aeda3a720b6a847ff95 (diff)
svl: use std::rotate() in SfxUndoManager::ImplUndo()
Instead of manually moving out, moving a range and then moving in. Change-Id: Iaff461e1fcee3936c8ddc02bf471a804e7881aef Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125219 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
Diffstat (limited to 'svl')
-rw-r--r--svl/source/undo/undo.cxx16
1 files changed, 7 insertions, 9 deletions
diff --git a/svl/source/undo/undo.cxx b/svl/source/undo/undo.cxx
index e820a3cbb9d1..773d17313cea 100644
--- a/svl/source/undo/undo.cxx
+++ b/svl/source/undo/undo.cxx
@@ -689,15 +689,13 @@ bool SfxUndoManager::ImplUndo( SfxUndoContext* i_contextOrNull )
size_t nOffset = i_contextOrNull->GetUndoOffset();
if (nCurrent >= nOffset + 1)
{
- // Move out the action we want to execute.
- MarkedUndoAction aAction
- = std::move(m_xData->pActUndoArray->maUndoActions[nCurrent - 1 - nOffset]);
- // Move the actions after aAction down by one.
- std::move(m_xData->pActUndoArray->maUndoActions.data() + nCurrent - nOffset,
- m_xData->pActUndoArray->maUndoActions.data() + nCurrent,
- m_xData->pActUndoArray->maUndoActions.data() + nCurrent - nOffset - 1);
- // Move aAction to the top.
- m_xData->pActUndoArray->maUndoActions[nCurrent - 1] = std::move(aAction);
+ // Move the action we want to execute to the top of the undo stack.
+ // data() + nCurrent - nOffset - 1 is the start, data() + nCurrent - nOffset is what we
+ // want to move to the top, maUndoActions.data() + nCurrent is past the end/top of the
+ // undo stack.
+ std::rotate(m_xData->pActUndoArray->maUndoActions.data() + nCurrent - nOffset - 1,
+ m_xData->pActUndoArray->maUndoActions.data() + nCurrent - nOffset,
+ m_xData->pActUndoArray->maUndoActions.data() + nCurrent);
}
}