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(
pGlobal->mpDispatchWatcher);
// copy for execute
std::vector<DispatchWatcher::DispatchRequest> aTempList( aDispatchList );
aDispatchList.clear();
std::vector<DispatchWatcher::DispatchRequest> aTempList;
aTempList.swap( aDispatchList );
aGuard.clear();
......
......@@ -66,20 +66,14 @@ ObjectContact::~ObjectContact() COVERITY_NOEXCEPT_FALSE
// #i84257# To avoid that each 'delete pCandidate' again uses
// the local RemoveViewObjectContact with a search and removal in the
// vector, simply copy and clear local vector.
std::vector< ViewObjectContact* > aLocalVOCList(maViewObjectContactVector);
maViewObjectContactVector.clear();
while(!aLocalVOCList.empty())
{
ViewObjectContact* pCandidate = aLocalVOCList.back();
aLocalVOCList.pop_back();
DBG_ASSERT(pCandidate, "Corrupted ViewObjectContactList (!)");
std::vector< ViewObjectContact* > aLocalVOCList;
aLocalVOCList.swap(maViewObjectContactVector);
for (auto & pCandidate : aLocalVOCList)
// ViewObjectContacts only make sense with View and Object contacts.
// When the contact to the SdrObject is deleted like in this case,
// all ViewObjectContacts can be deleted, too.
delete pCandidate;
}
// assert when there were new entries added during deletion
DBG_ASSERT(maViewObjectContactVector.empty(), "Corrupted ViewObjectContactList (!)");
......
......@@ -55,20 +55,14 @@ void ViewContact::deleteAllVOCs()
// #i84257# To avoid that each 'delete pCandidate' again uses
// the local RemoveViewObjectContact with a search and removal in the
// vector, simply copy and clear local vector.
std::vector< ViewObjectContact* > aLocalVOCList(maViewObjectContactVector);
maViewObjectContactVector.clear();
while(!aLocalVOCList.empty())
{
ViewObjectContact* pCandidate = aLocalVOCList.back();
aLocalVOCList.pop_back();
DBG_ASSERT(pCandidate, "Corrupted ViewObjectContactList in VC (!)");
std::vector< ViewObjectContact* > aLocalVOCList;
aLocalVOCList.swap(maViewObjectContactVector);
for (auto & pCandidate : aLocalVOCList)
// ViewObjectContacts only make sense with View and Object contacts.
// When the contact to the SdrObject is deleted like in this case,
// all ViewObjectContacts can be deleted, too.
delete pCandidate;
}
// assert when there were new entries added during deletion
DBG_ASSERT(maViewObjectContactVector.empty(), "Corrupted ViewObjectContactList in VC (!)");
......
......@@ -2473,8 +2473,8 @@ void GtkSalFrame::createNewWindow( ::Window aNewParent, bool bXEmbed, SalX11Scre
if( bWasVisible )
Show( true );
std::list< GtkSalFrame* > aChildren = m_aChildren;
m_aChildren.clear();
std::list< GtkSalFrame* > aChildren;
aChildren.swap(m_aChildren);
for (auto const& child : aChildren)
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