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
This commit is contained in:
Miklos Vajna 2021-11-15 09:41:23 +01:00
parent c858a59158
commit 2a8506c2f2

View file

@ -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);
}
}