From 654c5272299057681d295afb76fc984b20868c7c Mon Sep 17 00:00:00 2001 From: Mike Kaganski Date: Thu, 21 Jan 2021 16:28:33 +0300 Subject: Use ContainerType().swap and avoid local variables Change-Id: I773555180758a97aff37f9bc27de83c355d71521 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109761 Tested-by: Jenkins Reviewed-by: Noel Grandin Reviewed-by: Mike Kaganski --- basegfx/source/range/b2dpolyrange.cxx | 7 ++----- comphelper/source/misc/accessiblewrapper.cxx | 6 ++---- connectivity/source/commontools/parameters.cxx | 6 ++---- connectivity/source/commontools/paramwrapper.cxx | 3 +-- connectivity/source/parse/sqlnode.cxx | 3 +-- dbaccess/source/core/api/StaticSet.cxx | 5 +---- dbaccess/source/core/dataaccess/ModelImpl.cxx | 3 +-- dbaccess/source/ui/dlg/sqlmessage.cxx | 5 +---- editeng/source/misc/hangulhanja.cxx | 5 +---- extensions/source/propctrlr/eventhandler.cxx | 6 ++---- extensions/source/propctrlr/pcrcommon.hxx | 3 +-- forms/source/helper/formnavigation.cxx | 3 +-- forms/source/richtext/richtextcontrol.cxx | 3 +-- hwpfilter/source/attributes.cxx | 3 +-- include/o3tl/lru_map.hxx | 3 +-- linguistic/source/hyphdsp.cxx | 3 +-- linguistic/source/iprcache.cxx | 3 +-- linguistic/source/thesdsp.cxx | 3 +-- reportdesign/source/core/misc/conditionalexpression.cxx | 3 +-- .../ui/framework/configuration/ChangeRequestQueueProcessor.cxx | 3 +-- svx/source/form/fmexch.cxx | 3 +-- svx/source/form/fmshimp.cxx | 6 ++---- svx/source/form/fmtextcontrolshell.cxx | 6 ++---- svx/source/form/navigatortree.cxx | 3 +-- sw/source/uibase/misc/glosdoc.cxx | 6 ++---- toolkit/source/controls/grid/defaultgridcolumnmodel.cxx | 3 +-- toolkit/source/controls/grid/defaultgriddatamodel.cxx | 8 ++------ toolkit/source/controls/grid/sortablegriddatamodel.cxx | 3 +-- toolkit/source/controls/unocontrols.cxx | 3 +-- vcl/osx/salframe.cxx | 3 +-- 30 files changed, 38 insertions(+), 85 deletions(-) diff --git a/basegfx/source/range/b2dpolyrange.cxx b/basegfx/source/range/b2dpolyrange.cxx index 21905e408167..d7d0d61de061 100644 --- a/basegfx/source/range/b2dpolyrange.cxx +++ b/basegfx/source/range/b2dpolyrange.cxx @@ -61,11 +61,8 @@ namespace basegfx void clear() { - std::vector aTmpRanges; - std::vector aTmpOrient; - - maRanges.swap(aTmpRanges); - maOrient.swap(aTmpOrient); + std::vector().swap(maRanges); + std::vector().swap(maOrient); maBounds.reset(); } diff --git a/comphelper/source/misc/accessiblewrapper.cxx b/comphelper/source/misc/accessiblewrapper.cxx index 4d4edb1393dc..19a118fd4bf9 100644 --- a/comphelper/source/misc/accessiblewrapper.cxx +++ b/comphelper/source/misc/accessiblewrapper.cxx @@ -79,8 +79,7 @@ namespace comphelper xComp->removeEventListener( this ); } // clear the map - AccessibleMap aMap; - m_aChildrenMap.swap( aMap ); + AccessibleMap().swap(m_aChildrenMap); } @@ -148,8 +147,7 @@ namespace comphelper } // clear our children - AccessibleMap aMap; - m_aChildrenMap.swap( aMap ); + AccessibleMap().swap(m_aChildrenMap); } diff --git a/connectivity/source/commontools/parameters.cxx b/connectivity/source/commontools/parameters.cxx index bd114ea19341..3eb116500e81 100644 --- a/connectivity/source/commontools/parameters.cxx +++ b/connectivity/source/commontools/parameters.cxx @@ -99,15 +99,13 @@ namespace dbtools m_pOuterParameters->dispose(); m_pOuterParameters = nullptr; m_nInnerCount = 0; - ParameterInformation aEmptyInfo; - m_aParameterInformation.swap( aEmptyInfo ); + ParameterInformation().swap(m_aParameterInformation); m_aMasterFields.clear(); m_aDetailFields.clear(); m_sIdentifierQuoteString.clear(); m_sSpecialCharacters.clear(); m_xConnectionMetadata.clear(); - std::vector< bool > aEmptyArray; - m_aParametersVisited.swap( aEmptyArray ); + std::vector< bool >().swap(m_aParametersVisited); m_bUpToDate = false; } diff --git a/connectivity/source/commontools/paramwrapper.cxx b/connectivity/source/commontools/paramwrapper.cxx index ffe42419daa6..17cb58cab220 100644 --- a/connectivity/source/commontools/paramwrapper.cxx +++ b/connectivity/source/commontools/paramwrapper.cxx @@ -343,8 +343,7 @@ namespace dbtools::param rxParam->dispose(); } - Parameters aEmpty; - m_aParameters.swap( aEmpty ); + Parameters().swap(m_aParameters); } diff --git a/connectivity/source/parse/sqlnode.cxx b/connectivity/source/parse/sqlnode.cxx index 77c1306d699d..387cc54d92b2 100644 --- a/connectivity/source/parse/sqlnode.cxx +++ b/connectivity/source/parse/sqlnode.cxx @@ -1496,8 +1496,7 @@ OSQLParser::~OSQLParser() // Is only set the first time, so we should delete it only when there are no more instances s_xLocaleData = nullptr; - RuleIDMap aEmpty; - s_aReverseRuleIDLookup.swap( aEmpty ); + RuleIDMap().swap(s_aReverseRuleIDLookup); } m_pParseTree = nullptr; } diff --git a/dbaccess/source/core/api/StaticSet.cxx b/dbaccess/source/core/api/StaticSet.cxx index 0a5bd2c2d5fe..61cfb0af736f 100644 --- a/dbaccess/source/core/api/StaticSet.cxx +++ b/dbaccess/source/core/api/StaticSet.cxx @@ -270,10 +270,7 @@ void OStaticSet::deleteRow(const ORowSetRow& _rDeleteRow ,const connectivity::OS void OStaticSet::reset(const Reference< XResultSet> &_xDriverSet) { OCacheSet::construct(_xDriverSet, m_sRowSetFilter); - { - ORowSetMatrix t; - m_aSet.swap(t); - } + ORowSetMatrix().swap(m_aSet); m_aSetIter = m_aSet.end(); m_bEnd = false; m_aSet.emplace_back(nullptr); // this is the beforefirst record diff --git a/dbaccess/source/core/dataaccess/ModelImpl.cxx b/dbaccess/source/core/dataaccess/ModelImpl.cxx index c24e2376e41a..0cc2389d78dd 100644 --- a/dbaccess/source/core/dataaccess/ModelImpl.cxx +++ b/dbaccess/source/core/dataaccess/ModelImpl.cxx @@ -567,8 +567,7 @@ bool ODatabaseModelImpl::objectHasMacros( const Reference< XStorage >& _rxContai void ODatabaseModelImpl::reset() { m_bReadOnly = false; - std::vector< TContentPtr > aEmptyContainers( 4 ); - m_aContainer.swap( aEmptyContainers ); + std::vector(4).swap(m_aContainer); if ( m_pStorageAccess.is() ) { diff --git a/dbaccess/source/ui/dlg/sqlmessage.cxx b/dbaccess/source/ui/dlg/sqlmessage.cxx index 39ba6dc8eed1..42024d9cf078 100644 --- a/dbaccess/source/ui/dlg/sqlmessage.cxx +++ b/dbaccess/source/ui/dlg/sqlmessage.cxx @@ -196,10 +196,7 @@ namespace void lcl_buildExceptionChain( const SQLExceptionInfo& _rErrorInfo, const ProviderFactory& _rFactory, ExceptionDisplayChain& _out_rChain ) { - { - ExceptionDisplayChain empty; - _out_rChain.swap( empty ); - } + ExceptionDisplayChain().swap(_out_rChain); SQLExceptionIteratorHelper iter( _rErrorInfo ); while ( iter.hasMoreElements() ) diff --git a/editeng/source/misc/hangulhanja.cxx b/editeng/source/misc/hangulhanja.cxx index 709b770bec8c..1eac907e55b6 100644 --- a/editeng/source/misc/hangulhanja.cxx +++ b/editeng/source/misc/hangulhanja.cxx @@ -620,10 +620,7 @@ namespace editeng void HangulHanjaConversion_Impl::DoDocumentConversion( ) { // clear the change-all list - it's to be re-initialized for every single document - { - StringMap aEmpty; - m_aChangeList.swap( aEmpty ); - } + StringMap().swap(m_aChangeList); // first of all, we need to guess the direction of our conversion - it is determined by the first // hangul or hanja character in the first text diff --git a/extensions/source/propctrlr/eventhandler.cxx b/extensions/source/propctrlr/eventhandler.cxx index 4ec979682aea..f20107448ccb 100644 --- a/extensions/source/propctrlr/eventhandler.cxx +++ b/extensions/source/propctrlr/eventhandler.cxx @@ -462,8 +462,7 @@ namespace pcr m_xComponent.set( _rxIntrospectee, UNO_QUERY_THROW ); m_bEventsMapInitialized = false; - EventMap aEmpty; - m_aEvents.swap( aEmpty ); + EventMap().swap(m_aEvents); m_bIsDialogElement = false; m_nGridColumnType = -1; @@ -824,8 +823,7 @@ namespace pcr void SAL_CALL EventHandler::disposing() { - EventMap aEmpty; - m_aEvents.swap( aEmpty ); + EventMap().swap(m_aEvents); m_xComponent.clear(); } diff --git a/extensions/source/propctrlr/pcrcommon.hxx b/extensions/source/propctrlr/pcrcommon.hxx index 4544ba244c4c..ccaa39136a15 100644 --- a/extensions/source/propctrlr/pcrcommon.hxx +++ b/extensions/source/propctrlr/pcrcommon.hxx @@ -58,8 +58,7 @@ namespace pcr template< class CONTAINER > void clearContainer( CONTAINER& _rContainer ) { - CONTAINER aEmpty; - _rContainer.swap( aEmpty ); + CONTAINER().swap(_rContainer); } diff --git a/forms/source/helper/formnavigation.cxx b/forms/source/helper/formnavigation.cxx index 5182b0544db6..547a5781649a 100644 --- a/forms/source/helper/formnavigation.cxx +++ b/forms/source/helper/formnavigation.cxx @@ -346,8 +346,7 @@ namespace frm { disconnectDispatchers( ); // no supported features anymore: - FeatureMap aEmpty; - m_aSupportedFeatures.swap( aEmpty ); + FeatureMap().swap(m_aSupportedFeatures); } OFormNavigationMapper::OFormNavigationMapper( const Reference< XComponentContext >& _rxORB ) diff --git a/forms/source/richtext/richtextcontrol.cxx b/forms/source/richtext/richtextcontrol.cxx index 256c257b2f2c..1514eca99729 100644 --- a/forms/source/richtext/richtextcontrol.cxx +++ b/forms/source/richtext/richtextcontrol.cxx @@ -304,8 +304,7 @@ namespace frm } } - AttributeDispatchers aEmpty; - m_aDispatchers.swap( aEmpty ); + AttributeDispatchers().swap(m_aDispatchers); } VCLXWindow::dispose(); diff --git a/hwpfilter/source/attributes.cxx b/hwpfilter/source/attributes.cxx index 1c0712b0f9ab..602165ba0c32 100644 --- a/hwpfilter/source/attributes.cxx +++ b/hwpfilter/source/attributes.cxx @@ -143,8 +143,7 @@ const OUString &sValue ) void AttributeListImpl::clear() { - std::vector dummy; - m_pImpl->vecAttribute.swap( dummy ); + std::vector().swap(m_pImpl->vecAttribute); assert( ! getLength() ); } diff --git a/include/o3tl/lru_map.hxx b/include/o3tl/lru_map.hxx index ce5a078bc352..dc8a102977dd 100644 --- a/include/o3tl/lru_map.hxx +++ b/include/o3tl/lru_map.hxx @@ -77,8 +77,7 @@ public: // Some code .e.g. SalBitmap likes to remove itself from a cache during it's destructor, which means we // get calls into lru_map while we are in destruction, so use the swap-and-clear idiom to avoid those problems. mLruMap.clear(); - list_t aLruListTemp; - aLruListTemp.swap(mLruList); + list_t().swap(mLruList); } void insert(key_value_pair_t& rPair) diff --git a/linguistic/source/hyphdsp.cxx b/linguistic/source/hyphdsp.cxx index be33885880d3..fe9906a260a6 100644 --- a/linguistic/source/hyphdsp.cxx +++ b/linguistic/source/hyphdsp.cxx @@ -65,8 +65,7 @@ HyphenatorDispatcher::~HyphenatorDispatcher() void HyphenatorDispatcher::ClearSvcList() { // release memory for each table entry - HyphSvcByLangMap_t aTmp; - aSvcMap.swap( aTmp ); + HyphSvcByLangMap_t().swap(aSvcMap); } diff --git a/linguistic/source/iprcache.cxx b/linguistic/source/iprcache.cxx index 14eee1dfc69b..cf9c4db0b266 100644 --- a/linguistic/source/iprcache.cxx +++ b/linguistic/source/iprcache.cxx @@ -201,8 +201,7 @@ void SpellCache::Flush() { MutexGuard aGuard( GetLinguMutex() ); // clear word list - LangWordList_t aEmpty; - aWordLists.swap( aEmpty ); + LangWordList_t().swap(aWordLists); } bool SpellCache::CheckWord( const OUString& rWord, LanguageType nLang ) diff --git a/linguistic/source/thesdsp.cxx b/linguistic/source/thesdsp.cxx index 284673d641a7..2ffe3642e324 100644 --- a/linguistic/source/thesdsp.cxx +++ b/linguistic/source/thesdsp.cxx @@ -65,8 +65,7 @@ ThesaurusDispatcher::~ThesaurusDispatcher() void ThesaurusDispatcher::ClearSvcList() { // release memory for each table entry - ThesSvcByLangMap_t aTmp; - aSvcMap.swap( aTmp ); + ThesSvcByLangMap_t().swap(aSvcMap); } diff --git a/reportdesign/source/core/misc/conditionalexpression.cxx b/reportdesign/source/core/misc/conditionalexpression.cxx index 25ccd140a6d6..d68c25c95a63 100644 --- a/reportdesign/source/core/misc/conditionalexpression.cxx +++ b/reportdesign/source/core/misc/conditionalexpression.cxx @@ -166,8 +166,7 @@ namespace rptui size_t ConditionalExpressionFactory::getKnownConditionalExpressions( ConditionalExpressions& _out_rCondExp ) { - ConditionalExpressions aEmpty; - _out_rCondExp.swap( aEmpty ); + ConditionalExpressions().swap(_out_rCondExp); _out_rCondExp[ eBetween ] = std::make_shared( "AND( ( $$ ) >= ( $1 ); ( $$ ) <= ( $2 ) )" ); _out_rCondExp[ eNotBetween ] = std::make_shared( "NOT( AND( ( $$ ) >= ( $1 ); ( $$ ) <= ( $2 ) ) )" ); diff --git a/sd/source/ui/framework/configuration/ChangeRequestQueueProcessor.cxx b/sd/source/ui/framework/configuration/ChangeRequestQueueProcessor.cxx index 576ff10d3b79..6d8edd3e911a 100644 --- a/sd/source/ui/framework/configuration/ChangeRequestQueueProcessor.cxx +++ b/sd/source/ui/framework/configuration/ChangeRequestQueueProcessor.cxx @@ -175,8 +175,7 @@ void ChangeRequestQueueProcessor::ProcessUntilEmpty() void ChangeRequestQueueProcessor::Clear() { ::osl::MutexGuard aGuard (maMutex); - ChangeRequestQueue aEmpty; - maQueue.swap(aEmpty); + ChangeRequestQueue().swap(maQueue); } } // end of namespace sd::framework diff --git a/svx/source/form/fmexch.cxx b/svx/source/form/fmexch.cxx index fe875b9e5cfc..38e5fbd947cb 100644 --- a/svx/source/form/fmexch.cxx +++ b/svx/source/form/fmexch.cxx @@ -228,8 +228,7 @@ namespace svxform void OControlTransferData::buildListFromPath(const weld::TreeView* pTreeBox, const weld::TreeIter* pRoot) { - ListBoxEntrySet aEmpty; - m_aSelectedEntries.swap( aEmpty ); + ListBoxEntrySet().swap(m_aSelectedEntries); for (const css::uno::Sequence& rPaths : std::as_const(m_aControlPaths)) { diff --git a/svx/source/form/fmshimp.cxx b/svx/source/form/fmshimp.cxx index 878f7f60f412..96f10415d48b 100644 --- a/svx/source/form/fmshimp.cxx +++ b/svx/source/form/fmshimp.cxx @@ -911,8 +911,7 @@ void FmXFormShell::disposing() m_xExtViewTriggerController = nullptr; m_xExternalDisplayedForm = nullptr; - InterfaceBag aEmpty; - m_aCurrentSelection.swap( aEmpty ); + InterfaceBag().swap(m_aCurrentSelection); m_aActiveControllerFeatures.dispose(); m_aNavControllerFeatures.dispose(); @@ -1407,8 +1406,7 @@ void FmXFormShell::ExecuteSearch_Lock() return; // a collection of all (logical) forms - FmFormArray aEmpty; - m_aSearchForms.swap( aEmpty ); + FmFormArray().swap(m_aSearchForms); ::std::vector< OUString > aContextNames; impl_collectFormSearchContexts_nothrow_Lock( m_pShell->GetCurPage()->GetForms(), OUString(), diff --git a/svx/source/form/fmtextcontrolshell.cxx b/svx/source/form/fmtextcontrolshell.cxx index 0d723fad96bc..d996e3baf970 100644 --- a/svx/source/form/fmtextcontrolshell.cxx +++ b/svx/source/form/fmtextcontrolshell.cxx @@ -1093,8 +1093,7 @@ namespace svx rpObserver->dispose(); } - FocusListenerAdapters aEmpty; - m_aControlObservers.swap( aEmpty ); + FocusListenerAdapters().swap(m_aControlObservers); m_xActiveController.clear(); } @@ -1108,8 +1107,7 @@ namespace svx rFeature.second->dispose(); } - ControlFeatures aEmpty; - m_aControlFeatures.swap( aEmpty ); + ControlFeatures().swap(m_aControlFeatures); if ( m_aContextMenuObserver ) { diff --git a/svx/source/form/navigatortree.cxx b/svx/source/form/navigatortree.cxx index 4d6fc09559b8..7f55e21897e8 100644 --- a/svx/source/form/navigatortree.cxx +++ b/svx/source/form/navigatortree.cxx @@ -1453,8 +1453,7 @@ namespace svxform continue; m_xTreeView->set_sensitive(*rEntry, true); } - ListBoxEntrySet aEmpty; - m_aCutEntries.swap( aEmpty ); + ListBoxEntrySet().swap(m_aCutEntries); m_bKeyboardCut = false; } diff --git a/sw/source/uibase/misc/glosdoc.cxx b/sw/source/uibase/misc/glosdoc.cxx index 181f8c7247e1..9d7b95aae140 100644 --- a/sw/source/uibase/misc/glosdoc.cxx +++ b/sw/source/uibase/misc/glosdoc.cxx @@ -506,8 +506,7 @@ void SwGlossaries::InvalidateUNOOjects() if ( xGroup.is() ) static_cast< SwXAutoTextGroup* >( xGroup.get() )->Invalidate(); } - UnoAutoTextGroups aTmpg; - m_aGlossaryGroups.swap( aTmpg ); + UnoAutoTextGroups().swap(m_aGlossaryGroups); // invalidate all the AutoTextEntry-objects for (const auto& rEntry : m_aGlossaryEntries) @@ -516,8 +515,7 @@ void SwGlossaries::InvalidateUNOOjects() if ( pEntry ) pEntry->Invalidate(); } - UnoAutoTextEntries aTmpe; - m_aGlossaryEntries.swap( aTmpe ); + UnoAutoTextEntries().swap(m_aGlossaryEntries); } Reference< text::XAutoTextGroup > SwGlossaries::GetAutoTextGroup( const OUString& _rGroupName ) diff --git a/toolkit/source/controls/grid/defaultgridcolumnmodel.cxx b/toolkit/source/controls/grid/defaultgridcolumnmodel.cxx index 8b97158d0df0..3d65945cede3 100644 --- a/toolkit/source/controls/grid/defaultgridcolumnmodel.cxx +++ b/toolkit/source/controls/grid/defaultgridcolumnmodel.cxx @@ -369,8 +369,7 @@ private: m_aColumns.erase( m_aColumns.begin() ); } - Columns aEmpty; - m_aColumns.swap( aEmpty ); + Columns().swap(m_aColumns); } diff --git a/toolkit/source/controls/grid/defaultgriddatamodel.cxx b/toolkit/source/controls/grid/defaultgriddatamodel.cxx index c700ad79b344..f6c1beb9f14a 100644 --- a/toolkit/source/controls/grid/defaultgriddatamodel.cxx +++ b/toolkit/source/controls/grid/defaultgriddatamodel.cxx @@ -466,12 +466,8 @@ private: rBHelper.aLC.disposeAndClear( aEvent ); ::osl::MutexGuard aGuard( m_aMutex ); - GridData aEmptyData; - m_aData.swap( aEmptyData ); - - ::std::vector< Any > aEmptyRowHeaders; - m_aRowHeaders.swap( aEmptyRowHeaders ); - + GridData().swap(m_aData); + std::vector().swap(m_aRowHeaders); m_nColumnCount = 0; } diff --git a/toolkit/source/controls/grid/sortablegriddatamodel.cxx b/toolkit/source/controls/grid/sortablegriddatamodel.cxx index ffbb6528dc62..ffd9b0f9067b 100644 --- a/toolkit/source/controls/grid/sortablegriddatamodel.cxx +++ b/toolkit/source/controls/grid/sortablegriddatamodel.cxx @@ -213,8 +213,7 @@ public: template< class STLCONTAINER > void lcl_clear( STLCONTAINER& i_container ) { - STLCONTAINER empty; - empty.swap( i_container ); + STLCONTAINER().swap(i_container); } SortableGridDataModel::SortableGridDataModel( Reference< XComponentContext > const & rxContext ) diff --git a/toolkit/source/controls/unocontrols.cxx b/toolkit/source/controls/unocontrols.cxx index fde094051708..0a7457239c43 100644 --- a/toolkit/source/controls/unocontrols.cxx +++ b/toolkit/source/controls/unocontrols.cxx @@ -2026,8 +2026,7 @@ struct UnoControlListBoxModel_Data void removeAllItems() { - ::std::vector< ListItem > aEmpty; - m_aListItems.swap( aEmpty ); + std::vector().swap(m_aListItems); } public: diff --git a/vcl/osx/salframe.cxx b/vcl/osx/salframe.cxx index 9d4f68827a06..c00a976db96a 100644 --- a/vcl/osx/salframe.cxx +++ b/vcl/osx/salframe.cxx @@ -1798,8 +1798,7 @@ void AquaSalFrame::BeginSetClipRegion( sal_uInt32 nRects ) if( maClippingRects.size() > SAL_CLIPRECT_COUNT && nRects < maClippingRects.size() ) { - std::vector aEmptyVec; - maClippingRects.swap( aEmptyVec ); + std::vector().swap(maClippingRects); } maClippingRects.clear(); maClippingRects.reserve( nRects ); -- cgit