diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-05-06 13:09:43 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-05-07 14:23:51 +0200 |
commit | 09122ed302fd3d77718ee1a63d2ca4d5d7a0ace8 (patch) | |
tree | 2bd8c35db7098e3794668f2f3cee1761e9bee6ef /comphelper | |
parent | a93220b79faad8d679f3c67ccd967cdfac68d49f (diff) |
remove dead item cleanup from NumberedCollection::impl_searchFreeNumber
which speeds it up a little, because WeakReferences are a little slow
Change-Id: I76226b180ae4e11c4beb9e2f4ae12b05f980dcad
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133960
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'comphelper')
-rw-r--r-- | comphelper/source/misc/numberedcollection.cxx | 17 |
1 files changed, 3 insertions, 14 deletions
diff --git a/comphelper/source/misc/numberedcollection.cxx b/comphelper/source/misc/numberedcollection.cxx index efadf0fd5a6d..59088fe9c6b1 100644 --- a/comphelper/source/misc/numberedcollection.cxx +++ b/comphelper/source/misc/numberedcollection.cxx @@ -180,6 +180,7 @@ OUString SAL_CALL NumberedCollection::getUntitledPrefix() { // create ordered list of all possible numbers. std::vector< ::sal_Int32 > lPossibleNumbers; + lPossibleNumbers.reserve(m_lComponents.size() + 1); ::sal_Int32 c = static_cast<::sal_Int32>(m_lComponents.size ()); ::sal_Int32 i = 1; @@ -190,25 +191,13 @@ OUString SAL_CALL NumberedCollection::getUntitledPrefix() for (i=1; i<=c; ++i) lPossibleNumbers.push_back (i); - TDeadItemList lDeadItems; - - for (const auto& [rComponent, rItem] : m_lComponents) + for (const auto& rPair : m_lComponents) { - const css::uno::Reference< css::uno::XInterface > xItem = rItem.xItem.get(); - - if ( ! xItem.is ()) - { - lDeadItems.push_back(rComponent); - continue; - } - - std::vector< ::sal_Int32 >::iterator pPossible = std::find(lPossibleNumbers.begin (), lPossibleNumbers.end (), rItem.nNumber); + std::vector< ::sal_Int32 >::iterator pPossible = std::find(lPossibleNumbers.begin (), lPossibleNumbers.end (), rPair.second.nNumber); if (pPossible != lPossibleNumbers.end ()) lPossibleNumbers.erase (pPossible); } - impl_cleanUpDeadItems(m_lComponents, lDeadItems); - // a) non free numbers ... return INVALID_NUMBER if (lPossibleNumbers.empty()) return css::frame::UntitledNumbersConst::INVALID_NUMBER; |