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>
diff --git a/sw/inc/swtable.hxx b/sw/inc/swtable.hxx
index 21348a3..844ab31 100644
--- a/sw/inc/swtable.hxx
+++ b/sw/inc/swtable.hxx
@@ -433,7 +433,7 @@
// 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 66176656..eee79e9 100644
--- a/sw/source/core/table/swtable.cxx
+++ b/sw/source/core/table/swtable.cxx
@@ -1739,36 +1739,40 @@
return pRet;
}
void SwTableBox::ChgFrameFormat( SwTableBoxFormat* pNewFormat )
void SwTableBox::ChgFrameFormat( SwTableBoxFormat* pNewFormat, bool bNeedToReregister )
{
SwFrameFormat *pOld = GetFrameFormat();
SwIterator<SwCellFrame,SwFormat> aIter( *pOld );
// 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();
// 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.
// #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() )
// First, re-register the Frames.
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 dcd71a5..f385c11 100644
--- a/sw/source/filter/xml/xmltbli.cxx
+++ b/sw/source/filter/xml/xmltbli.cxx
@@ -1824,7 +1824,7 @@
{
// 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