summaryrefslogtreecommitdiff
path: root/sw/source/core/doc/doccorr.cxx
diff options
context:
space:
mode:
authorAshod Nakashian <ashodnakashian@yahoo.com>2015-10-26 10:03:50 -0400
committerBjörn Michaelsen <bjoern.michaelsen@canonical.com>2015-10-27 13:49:55 +0000
commitf99e8f84f5421076b6c0c10a592e43843eabd8ff (patch)
treeaee30001c62ece85b5e1ac40e9ab1e8f1e750696 /sw/source/core/doc/doccorr.cxx
parent973a4086d7a832398997f0c3f0705582e437f596 (diff)
Optimised UnoCrsrTbl cleanup for faster doc saving
SwDoc has weak_ptr list to notify UnoCrsr instances when the doc is about to die. These were updated when each UnoCrsr instance was destroyed. The first performance issue is the use of a list. This no doubt is done to avoid the overhead of removing items at arbitrary position from a vector. Performance tests show vector is faster with a large document and ~10k UnoCrsr instances. More important, there is no need to clean up the references as frequently as when each UnoCrsr is destroyed as they are rarely referenced at all. Having outdated references is no issue either. The new logic uses a vector and cleans up only after saving a document and before saving UnoCrsr instances. Saving ODT files is now significantly faster for large documents (100s of pages). Change-Id: I3895d9d80d174cda9c94b94837e2149e9fadcb42 Reviewed-on: https://gerrit.libreoffice.org/19604 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Björn Michaelsen <bjoern.michaelsen@canonical.com>
Diffstat (limited to 'sw/source/core/doc/doccorr.cxx')
-rw-r--r--sw/source/core/doc/doccorr.cxx94
1 files changed, 46 insertions, 48 deletions
diff --git a/sw/source/core/doc/doccorr.cxx b/sw/source/core/doc/doccorr.cxx
index 26b1371304e9..82bd250812de 100644
--- a/sw/source/core/doc/doccorr.cxx
+++ b/sw/source/core/doc/doccorr.cxx
@@ -120,47 +120,46 @@ void PaMCorrAbs( const SwPaM& rRange,
lcl_PaMCorrAbs( const_cast<SwPaM &>(*pCrsrShell->GetTableCrs()), aStart, aEnd, aNewPos );
}
}
+
+ for(const auto& pWeakUnoCrsr : pDoc->mvUnoCrsrTbl)
{
- for(auto pWeakUnoCrsr : pDoc->mvUnoCrsrTbl)
- {
- auto pUnoCursor(pWeakUnoCrsr.lock());
- if(!pUnoCursor)
- continue;
+ auto pUnoCursor(pWeakUnoCrsr.lock());
+ if(!pUnoCursor)
+ continue;
- bool bChange = false; // has the UNO cursor been corrected?
+ bool bChange = false; // has the UNO cursor been corrected?
- // determine whether the UNO cursor will leave it's designated
- // section
- bool const bLeaveSection =
- pUnoCursor->IsRemainInSection() &&
- ( lcl_FindUnoCrsrSection( aNewPos.nNode.GetNode() ) !=
- lcl_FindUnoCrsrSection(
- pUnoCursor->GetPoint()->nNode.GetNode() ) );
+ // determine whether the UNO cursor will leave it's designated
+ // section
+ bool const bLeaveSection =
+ pUnoCursor->IsRemainInSection() &&
+ ( lcl_FindUnoCrsrSection( aNewPos.nNode.GetNode() ) !=
+ lcl_FindUnoCrsrSection(
+ pUnoCursor->GetPoint()->nNode.GetNode() ) );
- for(SwPaM& rPaM : pUnoCursor->GetRingContainer())
- {
- bChange |= lcl_PaMCorrAbs( rPaM, aStart, aEnd, aNewPos );
- }
+ for(SwPaM& rPaM : pUnoCursor->GetRingContainer())
+ {
+ bChange |= lcl_PaMCorrAbs( rPaM, aStart, aEnd, aNewPos );
+ }
- SwUnoTableCrsr *const pUnoTblCrsr =
- dynamic_cast<SwUnoTableCrsr *>(pUnoCursor.get());
- if( pUnoTblCrsr )
+ SwUnoTableCrsr *const pUnoTblCrsr =
+ dynamic_cast<SwUnoTableCrsr *>(pUnoCursor.get());
+ if( pUnoTblCrsr )
+ {
+ for(SwPaM& rPaM : (&pUnoTblCrsr->GetSelRing())->GetRingContainer())
{
- for(SwPaM& rPaM : (&pUnoTblCrsr->GetSelRing())->GetRingContainer())
- {
- bChange |=
- lcl_PaMCorrAbs( rPaM, aStart, aEnd, aNewPos );
- }
+ bChange |=
+ lcl_PaMCorrAbs( rPaM, aStart, aEnd, aNewPos );
}
+ }
- // if a UNO cursor leaves its designated section, we must inform
- // (and invalidate) said cursor
- if (bChange && bLeaveSection)
- {
- // the UNO cursor has left its section. We need to notify it!
- SwMsgPoolItem aHint( RES_UNOCURSOR_LEAVES_SECTION );
- pUnoCursor->ModifyNotification( &aHint, NULL );
- }
+ // if a UNO cursor leaves its designated section, we must inform
+ // (and invalidate) said cursor
+ if (bChange && bLeaveSection)
+ {
+ // the UNO cursor has left its section. We need to notify it!
+ SwMsgPoolItem aHint( RES_UNOCURSOR_LEAVES_SECTION );
+ pUnoCursor->ModifyNotification( &aHint, NULL );
}
}
}
@@ -274,25 +273,24 @@ void PaMCorrRel( const SwNodeIndex &rOldNode,
lcl_PaMCorrRel1( pCrsrShell->GetTableCrs(), pOldNode, aNewPos, nCntIdx );
}
}
+
+ for(const auto& pWeakUnoCrsr : pDoc->mvUnoCrsrTbl)
{
- for(auto pWeakUnoCrsr : pDoc->mvUnoCrsrTbl)
+ auto pUnoCrsr(pWeakUnoCrsr.lock());
+ if(!pUnoCrsr)
+ continue;
+ for(SwPaM& rPaM : pUnoCrsr->GetRingContainer())
{
- auto pUnoCrsr(pWeakUnoCrsr.lock());
- if(!pUnoCrsr)
- continue;
- for(SwPaM& rPaM : pUnoCrsr->GetRingContainer())
- {
- lcl_PaMCorrRel1( &rPaM, pOldNode, aNewPos, nCntIdx );
- }
+ lcl_PaMCorrRel1( &rPaM, pOldNode, aNewPos, nCntIdx );
+ }
- SwUnoTableCrsr* pUnoTblCrsr =
- dynamic_cast<SwUnoTableCrsr*>(pUnoCrsr.get());
- if( pUnoTblCrsr )
+ SwUnoTableCrsr* pUnoTblCrsr =
+ dynamic_cast<SwUnoTableCrsr*>(pUnoCrsr.get());
+ if( pUnoTblCrsr )
+ {
+ for(SwPaM& rPaM : (&pUnoTblCrsr->GetSelRing())->GetRingContainer())
{
- for(SwPaM& rPaM : (&pUnoTblCrsr->GetSelRing())->GetRingContainer())
- {
- lcl_PaMCorrRel1( &rPaM, pOldNode, aNewPos, nCntIdx );
- }
+ lcl_PaMCorrRel1( &rPaM, pOldNode, aNewPos, nCntIdx );
}
}
}