diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2016-07-10 20:02:50 +0200 |
---|---|---|
committer | Noel Grandin <noelgrandin@gmail.com> | 2016-07-13 13:08:16 +0000 |
commit | 38ae35db26cd5bed2eabc90e1a02afeb4e0eff54 (patch) | |
tree | e564209f0f32585c5fcc90bafb61efcb433f01d1 /sw | |
parent | 176d54fa5dd4aeda1cc77a1e46b7bfff0c07b8ce (diff) |
tdf#84635 - Slow layout of large tables
Based on suggestion from Aron Budea.
And do something similar to most other places keeping vectors
of weak references where the code looks like it will hold more than
a few entries.
Measurements:
the 26 page file file takes
51s without my path
15s with this patch
the 69 page file file takes
5m28 without my path
51s with this patch
the 84 page file file takes
8m28 without my path
58s with this patch
Change-Id: I8da94c525fc73ebd969e0343c6f074be4f0063b1
Reviewed-on: https://gerrit.libreoffice.org/27093
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/inc/doc.hxx | 12 | ||||
-rw-r--r-- | sw/source/core/doc/doccorr.cxx | 2 | ||||
-rw-r--r-- | sw/source/core/doc/docnew.cxx | 1 | ||||
-rw-r--r-- | sw/source/uibase/misc/glosdoc.cxx | 10 |
4 files changed, 16 insertions, 9 deletions
diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx index edf54f94f003..cfaefece1ed1 100644 --- a/sw/inc/doc.hxx +++ b/sw/inc/doc.hxx @@ -1644,14 +1644,14 @@ public: std::vector< std::weak_ptr<SwUnoCursor> > mvUnoCursorTable; // Remove expired UnoCursor weak pointers the document keeps to notify about document death. - void cleanupUnoCursorTable() + void cleanupUnoCursorTable() const { + auto & rTable = const_cast<SwDoc*>(this)->mvUnoCursorTable; // In most cases we'll remove most of the elements. - std::vector< std::weak_ptr<SwUnoCursor> > unoCursorTable; - std::copy_if(mvUnoCursorTable.begin(), mvUnoCursorTable.end(), - std::back_inserter(unoCursorTable), - [](const std::weak_ptr<SwUnoCursor>& pWeakPtr) { return !pWeakPtr.expired(); }); - std::swap(mvUnoCursorTable, unoCursorTable); + rTable.erase( std::remove_if(rTable.begin(), + rTable.end(), + [] (std::weak_ptr<SwUnoCursor> const & x) { return x.expired(); }), + rTable.end()); } private: diff --git a/sw/source/core/doc/doccorr.cxx b/sw/source/core/doc/doccorr.cxx index e043c9137f6e..e207e856117d 100644 --- a/sw/source/core/doc/doccorr.cxx +++ b/sw/source/core/doc/doccorr.cxx @@ -121,6 +121,7 @@ void PaMCorrAbs( const SwPaM& rRange, } } + pDoc->cleanupUnoCursorTable(); for(const auto& pWeakUnoCursor : pDoc->mvUnoCursorTable) { auto pUnoCursor(pWeakUnoCursor.lock()); @@ -273,6 +274,7 @@ void PaMCorrRel( const SwNodeIndex &rOldNode, } } + pDoc->cleanupUnoCursorTable(); for(const auto& pWeakUnoCursor : pDoc->mvUnoCursorTable) { auto pUnoCursor(pWeakUnoCursor.lock()); diff --git a/sw/source/core/doc/docnew.cxx b/sw/source/core/doc/docnew.cxx index 0e34dd0679ce..80c148ba2539 100644 --- a/sw/source/core/doc/docnew.cxx +++ b/sw/source/core/doc/docnew.cxx @@ -425,6 +425,7 @@ SwDoc::~SwDoc() getIDocumentRedlineAccess().GetExtraRedlineTable().DeleteAndDestroyAll(); const sw::DocDisposingHint aHint; + cleanupUnoCursorTable(); for(const auto& pWeakCursor : mvUnoCursorTable) { auto pCursor(pWeakCursor.lock()); diff --git a/sw/source/uibase/misc/glosdoc.cxx b/sw/source/uibase/misc/glosdoc.cxx index 0e054e5b125a..720bfcfdc8a1 100644 --- a/sw/source/uibase/misc/glosdoc.cxx +++ b/sw/source/uibase/misc/glosdoc.cxx @@ -442,18 +442,22 @@ void SwGlossaries::RemoveFileFromList( const OUString& rGroup ) // tell the UNO AutoTextGroup object that it's not valid anymore for ( UnoAutoTextGroups::iterator aLoop = m_aGlossaryGroups.begin(); aLoop != m_aGlossaryGroups.end(); - ++aLoop ) { Reference< container::XNamed > xNamed( aLoop->get(), UNO_QUERY ); - if ( xNamed.is() && ( xNamed->getName() == rGroup ) ) + if ( !xNamed.is() ) + { + aLoop = m_aGlossaryGroups.erase(aLoop); + } + else if ( xNamed->getName() == rGroup ) { static_cast< SwXAutoTextGroup* >( xNamed.get() )->Invalidate(); // note that this static_cast works because we know that the array only // contains SwXAutoTextGroup implementation m_aGlossaryGroups.erase( aLoop ); break; - } + } else + ++aLoop; } } |