[Libreoffice-commits] core.git: Branch 'libreoffice-7-0' - include/svl svl/source sw/source

Noel Grandin (via logerrit) logerrit at kemper.freedesktop.org
Thu Sep 10 18:52:41 UTC 2020


 include/svl/undo.hxx            |    2 +-
 svl/source/undo/undo.cxx        |   12 ++++++++----
 sw/source/core/undo/docundo.cxx |    6 ++----
 3 files changed, 11 insertions(+), 9 deletions(-)

New commits:
commit 505784b6840295ce1ffd33704ce91b4018a16c20
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Thu Sep 10 14:27:55 2020 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Thu Sep 10 20:51:41 2020 +0200

    tdf#136238 speed up deleting large cross page table
    
    Goes from more than 30s to less than 1s on my pc.
    
    We were getting stuck inside the loop in sw::UndoManager::AddUndoAction,
    because the RemoveOldestUndoAction was continually doing nothing because
    it was hitting the
      if ( IsInListAction()
      {
    assert(!"SfxUndoManager::RemoveOldestUndoActions: cannot remove a
    not-yet-closed list action!");
        return;
     }
    
    code.
    
    Which means that there is some bug here, but I'm not sure what. We are
    deep inside the delete logic at that point, and it doesn't seem
    unreasonable to opportunistically delete some of the UNDO list at that
    point.
    
    So the real fix is just the conversion from a while loop to an if-check.
    
    Change-Id: Ie2707009dd6574b996421f67d952ab9fdaaaf6aa
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102378
    Tested-by: Noel Grandin <noel.grandin at collabora.co.uk>
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
    (cherry picked from commit da5c289a9cae5d914937f235694fd5b0cb92547f)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102313
    Tested-by: Jenkins

diff --git a/include/svl/undo.hxx b/include/svl/undo.hxx
index 8de6231c1dc5..89bfb5dbbaa2 100644
--- a/include/svl/undo.hxx
+++ b/include/svl/undo.hxx
@@ -289,7 +289,7 @@ public:
 
     /** removes the oldest Undo actions from the stack
     */
-    void            RemoveOldestUndoAction();
+    void            RemoveOldestUndoActions(sal_Int32 nNumToDelete);
 
     void dumpAsXml(xmlTextWriterPtr pWriter) const;
 
diff --git a/svl/source/undo/undo.cxx b/svl/source/undo/undo.cxx
index b678fba83948..46c785557416 100644
--- a/svl/source/undo/undo.cxx
+++ b/svl/source/undo/undo.cxx
@@ -1123,18 +1123,22 @@ bool SfxUndoManager::HasTopUndoActionMark( UndoStackMark const i_mark )
 }
 
 
-void SfxUndoManager::RemoveOldestUndoAction()
+void SfxUndoManager::RemoveOldestUndoActions(sal_Int32 nNumToDelete)
 {
     UndoManagerGuard aGuard( *m_xData );
 
-    if ( IsInListAction() && ( m_xData->pUndoArray->nCurUndoAction == 1 ) )
+    if ( ImplIsInListAction_Lock() && ( m_xData->pUndoArray->nCurUndoAction == 1 ) )
     {
         assert(!"SfxUndoManager::RemoveOldestUndoActions: cannot remove a not-yet-closed list action!");
         return;
     }
 
-    aGuard.markForDeletion( m_xData->pUndoArray->Remove( 0 ) );
-    --m_xData->pUndoArray->nCurUndoAction;
+    while (nNumToDelete>0 && !m_xData->pUndoArray->maUndoActions.empty())
+    {
+        aGuard.markForDeletion( m_xData->pUndoArray->Remove( 0 ) );
+        --m_xData->pUndoArray->nCurUndoAction;
+        --nNumToDelete;
+    }
     ImplCheckEmptyActions();
 }
 
diff --git a/sw/source/core/undo/docundo.cxx b/sw/source/core/undo/docundo.cxx
index 61629e087bc7..e30c4ef72d88 100644
--- a/sw/source/core/undo/docundo.cxx
+++ b/sw/source/core/undo/docundo.cxx
@@ -535,10 +535,8 @@ void UndoManager::AddUndoAction(std::unique_ptr<SfxUndoAction> pAction, bool bTr
     }
 
     // if the undo nodes array is too large, delete some actions
-    while (UNDO_ACTION_LIMIT < GetUndoNodes().Count())
-    {
-        RemoveOldestUndoAction();
-    }
+    if (UNDO_ACTION_LIMIT < GetUndoNodes().Count())
+        RemoveOldestUndoActions(GetUndoNodes().Count() - UNDO_ACTION_LIMIT);
 }
 
 namespace {


More information about the Libreoffice-commits mailing list