Kaydet (Commit) d49e2e46 authored tarafından Noel Grandin's avatar Noel Grandin

use std::<some_container>::swap, instead of copy and clear

Change-Id: If49c33e271426ff5c2d0c6cc4010670f797bdd38
Reviewed-on: https://gerrit.libreoffice.org/65001
Tested-by: Jenkins
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst e4e28359
...@@ -1343,8 +1343,8 @@ bool RequestHandler::ExecuteCmdLineRequests( ...@@ -1343,8 +1343,8 @@ bool RequestHandler::ExecuteCmdLineRequests(
pGlobal->mpDispatchWatcher); pGlobal->mpDispatchWatcher);
// copy for execute // copy for execute
std::vector<DispatchWatcher::DispatchRequest> aTempList( aDispatchList ); std::vector<DispatchWatcher::DispatchRequest> aTempList;
aDispatchList.clear(); aTempList.swap( aDispatchList );
aGuard.clear(); aGuard.clear();
......
...@@ -66,20 +66,14 @@ ObjectContact::~ObjectContact() COVERITY_NOEXCEPT_FALSE ...@@ -66,20 +66,14 @@ ObjectContact::~ObjectContact() COVERITY_NOEXCEPT_FALSE
// #i84257# To avoid that each 'delete pCandidate' again uses // #i84257# To avoid that each 'delete pCandidate' again uses
// the local RemoveViewObjectContact with a search and removal in the // the local RemoveViewObjectContact with a search and removal in the
// vector, simply copy and clear local vector. // vector, simply copy and clear local vector.
std::vector< ViewObjectContact* > aLocalVOCList(maViewObjectContactVector); std::vector< ViewObjectContact* > aLocalVOCList;
maViewObjectContactVector.clear(); aLocalVOCList.swap(maViewObjectContactVector);
while(!aLocalVOCList.empty())
{
ViewObjectContact* pCandidate = aLocalVOCList.back();
aLocalVOCList.pop_back();
DBG_ASSERT(pCandidate, "Corrupted ViewObjectContactList (!)");
for (auto & pCandidate : aLocalVOCList)
// ViewObjectContacts only make sense with View and Object contacts. // ViewObjectContacts only make sense with View and Object contacts.
// When the contact to the SdrObject is deleted like in this case, // When the contact to the SdrObject is deleted like in this case,
// all ViewObjectContacts can be deleted, too. // all ViewObjectContacts can be deleted, too.
delete pCandidate; delete pCandidate;
}
// assert when there were new entries added during deletion // assert when there were new entries added during deletion
DBG_ASSERT(maViewObjectContactVector.empty(), "Corrupted ViewObjectContactList (!)"); DBG_ASSERT(maViewObjectContactVector.empty(), "Corrupted ViewObjectContactList (!)");
......
...@@ -55,20 +55,14 @@ void ViewContact::deleteAllVOCs() ...@@ -55,20 +55,14 @@ void ViewContact::deleteAllVOCs()
// #i84257# To avoid that each 'delete pCandidate' again uses // #i84257# To avoid that each 'delete pCandidate' again uses
// the local RemoveViewObjectContact with a search and removal in the // the local RemoveViewObjectContact with a search and removal in the
// vector, simply copy and clear local vector. // vector, simply copy and clear local vector.
std::vector< ViewObjectContact* > aLocalVOCList(maViewObjectContactVector); std::vector< ViewObjectContact* > aLocalVOCList;
maViewObjectContactVector.clear(); aLocalVOCList.swap(maViewObjectContactVector);
while(!aLocalVOCList.empty())
{
ViewObjectContact* pCandidate = aLocalVOCList.back();
aLocalVOCList.pop_back();
DBG_ASSERT(pCandidate, "Corrupted ViewObjectContactList in VC (!)");
for (auto & pCandidate : aLocalVOCList)
// ViewObjectContacts only make sense with View and Object contacts. // ViewObjectContacts only make sense with View and Object contacts.
// When the contact to the SdrObject is deleted like in this case, // When the contact to the SdrObject is deleted like in this case,
// all ViewObjectContacts can be deleted, too. // all ViewObjectContacts can be deleted, too.
delete pCandidate; delete pCandidate;
}
// assert when there were new entries added during deletion // assert when there were new entries added during deletion
DBG_ASSERT(maViewObjectContactVector.empty(), "Corrupted ViewObjectContactList in VC (!)"); DBG_ASSERT(maViewObjectContactVector.empty(), "Corrupted ViewObjectContactList in VC (!)");
......
...@@ -2473,8 +2473,8 @@ void GtkSalFrame::createNewWindow( ::Window aNewParent, bool bXEmbed, SalX11Scre ...@@ -2473,8 +2473,8 @@ void GtkSalFrame::createNewWindow( ::Window aNewParent, bool bXEmbed, SalX11Scre
if( bWasVisible ) if( bWasVisible )
Show( true ); Show( true );
std::list< GtkSalFrame* > aChildren = m_aChildren; std::list< GtkSalFrame* > aChildren;
m_aChildren.clear(); aChildren.swap(m_aChildren);
for (auto const& child : aChildren) for (auto const& child : aChildren)
child->createNewWindow( None, false, m_nXScreen ); child->createNewWindow( None, false, m_nXScreen );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment