[Libreoffice-commits] core.git: desktop/source svx/source vcl/unx

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Wed Dec 12 09:56:22 UTC 2018


 desktop/source/app/officeipcthread.cxx   |    4 ++--
 svx/source/sdr/contact/objectcontact.cxx |   12 +++---------
 svx/source/sdr/contact/viewcontact.cxx   |   12 +++---------
 vcl/unx/gtk/gtksalframe.cxx              |    4 ++--
 4 files changed, 10 insertions(+), 22 deletions(-)

New commits:
commit d49e2e46099e3599bdc8d81efe9ee8bd1cdcb6ee
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Wed Dec 12 10:47:46 2018 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Wed Dec 12 10:55:57 2018 +0100

    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 at collabora.co.uk>

diff --git a/desktop/source/app/officeipcthread.cxx b/desktop/source/app/officeipcthread.cxx
index 80432dd12d3f..3b7ba4633d06 100644
--- a/desktop/source/app/officeipcthread.cxx
+++ b/desktop/source/app/officeipcthread.cxx
@@ -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();
 
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 (!)");
diff --git a/vcl/unx/gtk/gtksalframe.cxx b/vcl/unx/gtk/gtksalframe.cxx
index a4e6e0fdcd2d..8b420b49793f 100644
--- a/vcl/unx/gtk/gtksalframe.cxx
+++ b/vcl/unx/gtk/gtksalframe.cxx
@@ -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 );
 


More information about the Libreoffice-commits mailing list