[Libreoffice-commits] core.git: sw/inc sw/source

Noel Grandin (via logerrit) logerrit at kemper.freedesktop.org
Fri Mar 29 06:30:27 UTC 2019


 sw/inc/swtable.hxx               |    2 -
 sw/source/core/table/swtable.cxx |   48 +++++++++++++++++++++------------------
 sw/source/filter/xml/xmltbli.cxx |    2 -
 3 files changed, 28 insertions(+), 24 deletions(-)

New commits:
commit 912742333b67c08f7d65c200efabd5fab00b907f
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Thu Mar 28 13:13:22 2019 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Fri Mar 29 07:29:54 2019 +0100

    tdf#84635 quadratic slowdown on loading large tables
    
    skip the re-registration scan in SwTableBox::ChgFrameFormat, which we
    don't need since we are creating this table for the first time
    
    On my machine,
    loading the  69 page file goes from 40.9s to 30.4s
    loading the 128 page file goes from 79.1s to 45.1s
    
    Change-Id: Id9e48256556e19eca34a892b29beff7eab9f51f1
    Reviewed-on: https://gerrit.libreoffice.org/69885
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
    Tested-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/sw/inc/swtable.hxx b/sw/inc/swtable.hxx
index 21348a36662b..844ab31497e0 100644
--- a/sw/inc/swtable.hxx
+++ b/sw/inc/swtable.hxx
@@ -433,7 +433,7 @@ public:
 
     // Creates its own FrameFormat if more boxes depend on it.
     SwFrameFormat* ClaimFrameFormat();
-    void ChgFrameFormat( SwTableBoxFormat *pNewFormat );
+    void ChgFrameFormat( SwTableBoxFormat *pNewFormat, bool bNeedToReregister = true );
 
     void RemoveFromTable();
     const SwStartNode *GetSttNd() const { return m_pStartNode; }
diff --git a/sw/source/core/table/swtable.cxx b/sw/source/core/table/swtable.cxx
index 6617665698ea..eee79e9e8354 100644
--- a/sw/source/core/table/swtable.cxx
+++ b/sw/source/core/table/swtable.cxx
@@ -1739,36 +1739,40 @@ SwFrameFormat* SwTableBox::ClaimFrameFormat()
     return pRet;
 }
 
-void SwTableBox::ChgFrameFormat( SwTableBoxFormat* pNewFormat )
+void SwTableBox::ChgFrameFormat( SwTableBoxFormat* pNewFormat, bool bNeedToReregister )
 {
     SwFrameFormat *pOld = GetFrameFormat();
     SwIterator<SwCellFrame,SwFormat> aIter( *pOld );
 
+    // tdf#84635 We set bNeedToReregister=false to avoid a quadratic slowdown on loading large tables,
+    // and since we are creating the table for the first time, no re-registration is necessary.
+
     // First, re-register the Frames.
-    for( SwCellFrame* pCell = aIter.First(); pCell; pCell = aIter.Next() )
-    {
-        if( pCell->GetTabBox() == this )
-        {
-            pCell->RegisterToFormat( *pNewFormat );
-            pCell->InvalidateSize();
-            pCell->InvalidatePrt_();
-            pCell->SetCompletePaint();
-            pCell->SetDerivedVert( false );
-            pCell->CheckDirChange();
-
-            // #i47489#
-            // make sure that the row will be formatted, in order
-            // to have the correct Get(Top|Bottom)MarginForLowers values
-            // set at the row.
-            const SwTabFrame* pTab = pCell->FindTabFrame();
-            if ( pTab && pTab->IsCollapsingBorders() )
+    if (bNeedToReregister)
+        for( SwCellFrame* pCell = aIter.First(); pCell; pCell = aIter.Next() )
+        {
+            if( pCell->GetTabBox() == this )
             {
-                SwFrame* pRow = pCell->GetUpper();
-                pRow->InvalidateSize_();
-                pRow->InvalidatePrt_();
+                pCell->RegisterToFormat( *pNewFormat );
+                pCell->InvalidateSize();
+                pCell->InvalidatePrt_();
+                pCell->SetCompletePaint();
+                pCell->SetDerivedVert( false );
+                pCell->CheckDirChange();
+
+                // #i47489#
+                // make sure that the row will be formatted, in order
+                // to have the correct Get(Top|Bottom)MarginForLowers values
+                // set at the row.
+                const SwTabFrame* pTab = pCell->FindTabFrame();
+                if ( pTab && pTab->IsCollapsingBorders() )
+                {
+                    SwFrame* pRow = pCell->GetUpper();
+                    pRow->InvalidateSize_();
+                    pRow->InvalidatePrt_();
+                }
             }
         }
-    }
 
     // Now, re-register self.
     pNewFormat->Add( this );
diff --git a/sw/source/filter/xml/xmltbli.cxx b/sw/source/filter/xml/xmltbli.cxx
index dcd71a568259..f385c113b802 100644
--- a/sw/source/filter/xml/xmltbli.cxx
+++ b/sw/source/filter/xml/xmltbli.cxx
@@ -1824,7 +1824,7 @@ SwTableBoxFormat* SwXMLTableContext::GetSharedBoxFormat(
     {
         // set the shared format
         pBoxFormat2 = aIter->second;
-        pBox->ChgFrameFormat( pBoxFormat2 );
+        pBox->ChgFrameFormat( pBoxFormat2, /*bNeedToReregister*/false );
         bNew = false;   // copied from an existing format
 
         // claim it, if we are not allowed to share


More information about the Libreoffice-commits mailing list