[Libreoffice-commits] core.git: accessibility/source basic/source dbaccess/source svl/source sw/inc sw/source unotools/source
Noel Grandin
noelgrandin at gmail.com
Wed Jul 13 13:08:43 UTC 2016
accessibility/source/standard/vclxaccessiblelist.cxx | 12 ++++++----
basic/source/classes/sbunoobj.cxx | 8 +-----
dbaccess/source/core/dataaccess/ModelImpl.cxx | 13 +++++++----
svl/source/filepicker/pickerhistory.cxx | 22 +++----------------
sw/inc/doc.hxx | 12 +++++-----
sw/source/core/doc/doccorr.cxx | 2 +
sw/source/core/doc/docnew.cxx | 1
sw/source/uibase/misc/glosdoc.cxx | 10 ++++++--
unotools/source/config/cmdoptions.cxx | 9 +++++--
unotools/source/config/eventcfg.cxx | 9 +++++--
10 files changed, 51 insertions(+), 47 deletions(-)
New commits:
commit 38ae35db26cd5bed2eabc90e1a02afeb4e0eff54
Author: Noel Grandin <noelgrandin at gmail.com>
Date: Sun Jul 10 20:02:50 2016 +0200
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 at libreoffice.org>
Reviewed-by: Noel Grandin <noelgrandin at gmail.com>
diff --git a/accessibility/source/standard/vclxaccessiblelist.cxx b/accessibility/source/standard/vclxaccessiblelist.cxx
index 66e1fa2..b439dd1 100644
--- a/accessibility/source/standard/vclxaccessiblelist.cxx
+++ b/accessibility/source/standard/vclxaccessiblelist.cxx
@@ -165,19 +165,23 @@ void VCLXAccessibleList::notifyVisibleStates(bool _bSetNew )
NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
ListItems::iterator aIter = m_aAccessibleChildren.begin();
- ListItems::iterator aEnd = m_aAccessibleChildren.end();
UpdateVisibleLineCount();
// adjust the index inside the VCLXAccessibleListItem
- for (;aIter != aEnd ; ++aIter)
+ for ( ; aIter != m_aAccessibleChildren.end(); )
{
Reference< XAccessible > xHold = *aIter;
- VCLXAccessibleListItem* pItem = static_cast<VCLXAccessibleListItem*>(xHold.get());
- if ( pItem )
+ if (!xHold.is())
{
+ aIter = m_aAccessibleChildren.erase(aIter);
+ }
+ else
+ {
+ VCLXAccessibleListItem* pItem = static_cast<VCLXAccessibleListItem*>(xHold.get());
const sal_Int32 nTopEntry = m_pListBoxHelper ? m_pListBoxHelper->GetTopEntry() : 0;
const sal_Int32 nPos = static_cast<sal_Int32>(aIter - m_aAccessibleChildren.begin());
bool bVisible = ( nPos>=nTopEntry && nPos<( nTopEntry + m_nVisibleLineCount ) );
pItem->SetVisible( m_bVisible && bVisible );
+ ++aIter;
}
}
diff --git a/basic/source/classes/sbunoobj.cxx b/basic/source/classes/sbunoobj.cxx
index 370ae20..21be5c9 100644
--- a/basic/source/classes/sbunoobj.cxx
+++ b/basic/source/classes/sbunoobj.cxx
@@ -4576,13 +4576,9 @@ void disposeComVariablesForBasic( StarBASIC* pBasic )
ComponentRefVector::iterator itCRV;
for( itCRV = rv.begin() ; itCRV != rv.end() ; ++itCRV )
{
- try
- {
- Reference< XComponent > xComponent( (*itCRV).get(), UNO_QUERY_THROW );
+ Reference< XComponent > xComponent( (*itCRV).get(), UNO_QUERY );
+ if (xComponent.is())
xComponent->dispose();
- }
- catch(const Exception& )
- {}
}
delete pItem;
diff --git a/dbaccess/source/core/dataaccess/ModelImpl.cxx b/dbaccess/source/core/dataaccess/ModelImpl.cxx
index 4577776..d40a8f5 100644
--- a/dbaccess/source/core/dataaccess/ModelImpl.cxx
+++ b/dbaccess/source/core/dataaccess/ModelImpl.cxx
@@ -626,15 +626,20 @@ void SAL_CALL ODatabaseModelImpl::disposing( const css::lang::EventObject& Sourc
if ( xCon.is() )
{
bool bStore = false;
- OWeakConnectionArray::const_iterator aEnd = m_aConnections.end();
- for (OWeakConnectionArray::iterator i = m_aConnections.begin(); aEnd != i; ++i)
+ for (OWeakConnectionArray::iterator i = m_aConnections.begin(); i != m_aConnections.end(); )
{
- if ( xCon == i->get() )
+ css::uno::Reference< css::sdbc::XConnection > xIterConn ( *i );
+ if ( !xIterConn.is())
+ {
+ i = m_aConnections.erase(i);
+ }
+ else if ( xCon == xIterConn )
{
*i = css::uno::WeakReference< css::sdbc::XConnection >();
bStore = true;
break;
- }
+ } else
+ ++i;
}
if ( bStore )
diff --git a/svl/source/filepicker/pickerhistory.cxx b/svl/source/filepicker/pickerhistory.cxx
index 29cc03b..c4c4b03 100644
--- a/svl/source/filepicker/pickerhistory.cxx
+++ b/svl/source/filepicker/pickerhistory.cxx
@@ -50,24 +50,10 @@ namespace svt
return;
// first, check which of the objects we hold in s_aHistory can be removed
- {
- InterfaceArray aCleanedHistory;
- for ( InterfaceArray::const_iterator aLoop = _rHistory.begin();
- aLoop != _rHistory.end();
- ++aLoop
- )
- {
- Reference< XInterface > xCurrent( aLoop->get() );
- if ( xCurrent.is() )
- {
- if ( aCleanedHistory.empty() )
- // make some room, assume that all interfaces (from here on) are valid
- aCleanedHistory.reserve( _rHistory.size() - ( aLoop - _rHistory.begin() ) );
- aCleanedHistory.push_back( css::uno::WeakReference< XInterface >( xCurrent ) );
- }
- }
- _rHistory.swap( aCleanedHistory );
- }
+ _rHistory.erase(std::remove_if(_rHistory.begin(),
+ _rHistory.end(),
+ [](const css::uno::WeakReference< XInterface > & x) { return !x.get().is(); }),
+ _rHistory.end());
// then push_back the picker
_rHistory.push_back( css::uno::WeakReference< XInterface >( _rxPicker ) );
diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx
index edf54f9..cfaefec 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 e043c91..e207e85 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 0e34dd0..80c148b 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 0e054e5..720bfcf 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;
}
}
diff --git a/unotools/source/config/cmdoptions.cxx b/unotools/source/config/cmdoptions.cxx
index c79ba2a..0f53f1e 100644
--- a/unotools/source/config/cmdoptions.cxx
+++ b/unotools/source/config/cmdoptions.cxx
@@ -211,13 +211,16 @@ void SvtCommandOptions_Impl::Notify( const Sequence< OUString >& )
// don't forget to update all existing frames and her might cached dispatch objects!
// But look for already killed frames. We hold weak references instead of hard ones ...
- for (SvtFrameVector::const_iterator pIt = m_lFrames.begin();
- pIt != m_lFrames.end();
- ++pIt )
+ for (SvtFrameVector::iterator pIt = m_lFrames.begin(); pIt != m_lFrames.end(); )
{
css::uno::Reference< css::frame::XFrame > xFrame(pIt->get(), css::uno::UNO_QUERY);
if (xFrame.is())
+ {
xFrame->contextChanged();
+ ++pIt;
+ }
+ else
+ pIt = m_lFrames.erase(pIt);
}
}
diff --git a/unotools/source/config/eventcfg.cxx b/unotools/source/config/eventcfg.cxx
index 82907d5..0f968a8 100644
--- a/unotools/source/config/eventcfg.cxx
+++ b/unotools/source/config/eventcfg.cxx
@@ -146,13 +146,16 @@ void GlobalEventConfig_Impl::Notify( const Sequence< OUString >& )
// don't forget to update all existing frames and her might cached dispatch objects!
// But look for already killed frames. We hold weak references instead of hard ones ...
- for (FrameVector::const_iterator pIt = m_lFrames.begin();
- pIt != m_lFrames.end();
- ++pIt )
+ for (FrameVector::iterator pIt = m_lFrames.begin(); pIt != m_lFrames.end(); )
{
css::uno::Reference< css::frame::XFrame > xFrame(pIt->get(), css::uno::UNO_QUERY);
if (xFrame.is())
+ {
xFrame->contextChanged();
+ ++pIt;
+ }
+ else
+ pIt = m_lFrames.erase(pIt);
}
}
More information about the Libreoffice-commits
mailing list