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 <noel.grandin@collabora.co.uk>
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
This commit is contained in:
Mike Kaganski
2021-01-24 08:36:24 +01:00
parent b35f697156
commit 654c527229
30 changed files with 38 additions and 85 deletions
+2 -5
View File
@@ -61,11 +61,8 @@ namespace basegfx
void clear()
{
std::vector<B2DRange> aTmpRanges;
std::vector<B2VectorOrientation> aTmpOrient;
maRanges.swap(aTmpRanges);
maOrient.swap(aTmpOrient);
std::vector<B2DRange>().swap(maRanges);
std::vector<B2VectorOrientation>().swap(maOrient);
maBounds.reset();
}
+2 -4
View File
@@ -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);
}
@@ -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;
}
@@ -343,8 +343,7 @@ namespace dbtools::param
rxParam->dispose();
}
Parameters aEmpty;
m_aParameters.swap( aEmpty );
Parameters().swap(m_aParameters);
}
+1 -2
View File
@@ -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;
}
+1 -4
View File
@@ -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
@@ -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<TContentPtr>(4).swap(m_aContainer);
if ( m_pStorageAccess.is() )
{
+1 -4
View File
@@ -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() )
+1 -4
View File
@@ -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
+2 -4
View File
@@ -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();
}
+1 -2
View File
@@ -58,8 +58,7 @@ namespace pcr
template< class CONTAINER >
void clearContainer( CONTAINER& _rContainer )
{
CONTAINER aEmpty;
_rContainer.swap( aEmpty );
CONTAINER().swap(_rContainer);
}
+1 -2
View File
@@ -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 )
+1 -2
View File
@@ -304,8 +304,7 @@ namespace frm
}
}
AttributeDispatchers aEmpty;
m_aDispatchers.swap( aEmpty );
AttributeDispatchers().swap(m_aDispatchers);
}
VCLXWindow::dispose();
+1 -2
View File
@@ -143,8 +143,7 @@ const OUString &sValue )
void AttributeListImpl::clear()
{
std::vector<struct TagAttribute> dummy;
m_pImpl->vecAttribute.swap( dummy );
std::vector<struct TagAttribute>().swap(m_pImpl->vecAttribute);
assert( ! getLength() );
}
+1 -2
View File
@@ -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)
+1 -2
View File
@@ -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);
}
+1 -2
View File
@@ -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 )
+1 -2
View File
@@ -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);
}
@@ -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<ConditionalExpression>( "AND( ( $$ ) >= ( $1 ); ( $$ ) <= ( $2 ) )" );
_out_rCondExp[ eNotBetween ] = std::make_shared<ConditionalExpression>( "NOT( AND( ( $$ ) >= ( $1 ); ( $$ ) <= ( $2 ) ) )" );
@@ -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
+1 -2
View File
@@ -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<sal_uInt32>& rPaths : std::as_const(m_aControlPaths))
{
+2 -4
View File
@@ -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(),
+2 -4
View File
@@ -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 )
{
+1 -2
View File
@@ -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;
}
+2 -4
View File
@@ -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 )
@@ -369,8 +369,7 @@ private:
m_aColumns.erase( m_aColumns.begin() );
}
Columns aEmpty;
m_aColumns.swap( aEmpty );
Columns().swap(m_aColumns);
}
@@ -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<Any>().swap(m_aRowHeaders);
m_nColumnCount = 0;
}
@@ -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 )
+1 -2
View File
@@ -2026,8 +2026,7 @@ struct UnoControlListBoxModel_Data
void removeAllItems()
{
::std::vector< ListItem > aEmpty;
m_aListItems.swap( aEmpty );
std::vector<ListItem>().swap(m_aListItems);
}
public:
+1 -2
View File
@@ -1798,8 +1798,7 @@ void AquaSalFrame::BeginSetClipRegion( sal_uInt32 nRects )
if( maClippingRects.size() > SAL_CLIPRECT_COUNT && nRects < maClippingRects.size() )
{
std::vector<CGRect> aEmptyVec;
maClippingRects.swap( aEmptyVec );
std::vector<CGRect>().swap(maClippingRects);
}
maClippingRects.clear();
maClippingRects.reserve( nRects );