Kaydet (Commit) 91274233 authored tarafından Noel Grandin's avatar Noel Grandin

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/69885Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
Tested-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst 77192c1b
......@@ -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; }
......
......@@ -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 );
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment