diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-12-12 10:47:46 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-12-12 10:55:57 +0100 |
commit | d49e2e46099e3599bdc8d81efe9ee8bd1cdcb6ee (patch) | |
tree | 51e4e8136590a55681f57ac3e973a204768bc808 /svx | |
parent | e4e28359d688992deb8be5fbfdb3bcae855a7fe2 (diff) |
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: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'svx')
-rw-r--r-- | svx/source/sdr/contact/objectcontact.cxx | 12 | ||||
-rw-r--r-- | svx/source/sdr/contact/viewcontact.cxx | 12 |
2 files changed, 6 insertions, 18 deletions
diff --git a/svx/source/sdr/contact/objectcontact.cxx b/svx/source/sdr/contact/objectcontact.cxx index 058c5ddce7d6..09fc1f8015d6 100644 --- a/svx/source/sdr/contact/objectcontact.cxx +++ b/svx/source/sdr/contact/objectcontact.cxx @@ -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 (!)"); diff --git a/svx/source/sdr/contact/viewcontact.cxx b/svx/source/sdr/contact/viewcontact.cxx index 178c50f22bc1..d87e052b9436 100644 --- a/svx/source/sdr/contact/viewcontact.cxx +++ b/svx/source/sdr/contact/viewcontact.cxx @@ -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 (!)"); |