From 0250d6c643f2866c4de7e3c943248ffda9205d05 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Mon, 16 Jan 2023 09:19:36 +0100 Subject: [PATCH] sw, UpdateFieldContent: address a minor performance nit See , it's enough to start grouping undo/redo after we know that there is a relevant refmark under the cursor. Change-Id: I53e7e371768480d6b7e968c90bf8c5d9901013b9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145555 Tested-by: Jenkins Reviewed-by: Miklos Vajna --- sw/source/uibase/shells/basesh.cxx | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/sw/source/uibase/shells/basesh.cxx b/sw/source/uibase/shells/basesh.cxx index 44759890e695..363c37f9d580 100644 --- a/sw/source/uibase/shells/basesh.cxx +++ b/sw/source/uibase/shells/basesh.cxx @@ -913,16 +913,6 @@ void UpdateFieldContent(SfxRequest& rReq, SwWrtShell& rWrtSh) uno::Sequence aField; pField->GetValue() >>= aField; - SwDoc* pDoc = rWrtSh.GetDoc(); - pDoc->GetIDocumentUndoRedo().StartUndo(SwUndoId::INSBOOKMARK, nullptr); - rWrtSh.StartAction(); - comphelper::ScopeGuard g( - [&rWrtSh] - { - rWrtSh.EndAction(); - rWrtSh.GetDoc()->GetIDocumentUndoRedo().EndUndo(SwUndoId::INSBOOKMARK, nullptr); - }); - SwPosition& rCursor = *rWrtSh.GetCursor()->GetPoint(); SwTextNode* pTextNode = rCursor.GetNode().GetTextNode(); std::vector aAttrs @@ -938,6 +928,16 @@ void UpdateFieldContent(SfxRequest& rReq, SwWrtShell& rWrtSh) return; } + SwDoc* pDoc = rWrtSh.GetDoc(); + pDoc->GetIDocumentUndoRedo().StartUndo(SwUndoId::INSBOOKMARK, nullptr); + rWrtSh.StartAction(); + comphelper::ScopeGuard g( + [&rWrtSh] + { + rWrtSh.EndAction(); + rWrtSh.GetDoc()->GetIDocumentUndoRedo().EndUndo(SwUndoId::INSBOOKMARK, nullptr); + }); + comphelper::SequenceAsHashMap aMap(aField); auto aName = aMap["Name"].get(); rRefmark.GetRefName() = aName;