diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-03-28 13:13:22 +0200 |
---|---|---|
committer | Luboš Luňák <l.lunak@collabora.com> | 2021-03-23 15:57:13 +0100 |
commit | b3c890ad303f16e514ea30a96ec86dacb82b6e41 (patch) | |
tree | 015f64233e87dc5a2374ccfa1bd309ce2470120e | |
parent | do not disable Writer font caching on zoom mismatch (diff) | |
download | core-b3c890ad303f16e514ea30a96ec86dacb82b6e41.tar.gz core-b3c890ad303f16e514ea30a96ec86dacb82b6e41.zip |
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@collabora.co.uk>
Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r-- | sw/inc/swtable.hxx | 2 | ||||
-rw-r--r-- | sw/source/core/table/swtable.cxx | 48 | ||||
-rw-r--r-- | sw/source/filter/xml/xmltbli.cxx | 2 |
3 files changed, 28 insertions, 24 deletions
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 93f53065a7ca..82e3259e435e 100644 --- a/sw/source/core/table/swtable.cxx +++ b/sw/source/core/table/swtable.cxx @@ -1734,36 +1734,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 ed73304a7e5d..6ee095903afc 100644 --- a/sw/source/filter/xml/xmltbli.cxx +++ b/sw/source/filter/xml/xmltbli.cxx @@ -1921,7 +1921,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 |