[Libreoffice-commits] core.git: extensions/source starmath/source sw/source vcl/osx vcl/unx writerfilter/source

Julien Nabet serval2412 at yahoo.fr
Fri Feb 2 11:07:37 UTC 2018


 extensions/source/ole/servprov.cxx                    |    8 ++++----
 starmath/source/mathmlimport.cxx                      |    6 +++---
 sw/source/core/docnode/finalthreadmanager.cxx         |    6 +++---
 sw/source/core/text/redlnitr.cxx                      |   11 +++++------
 sw/source/filter/html/swhtml.cxx                      |   16 +++++++---------
 vcl/osx/clipboard.cxx                                 |    7 +++----
 vcl/unx/generic/dtrans/X11_clipboard.cxx              |    7 +++----
 vcl/unx/generic/print/printerjob.cxx                  |    5 ++---
 vcl/unx/generic/window/salframe.cxx                   |    8 ++++----
 writerfilter/source/rtftok/rtfdispatchdestination.cxx |    9 ++++-----
 10 files changed, 38 insertions(+), 45 deletions(-)

New commits:
commit d27ef675ec23f45562972da66bde02d99d778141
Author: Julien Nabet <serval2412 at yahoo.fr>
Date:   Thu Feb 1 16:42:19 2018 +0100

    Replace some front/pop_front by for-range loops+clear
    
    Change-Id: I8a9239667b0d80ee2fa6ebbc8a19ba4c0076c2fb
    Reviewed-on: https://gerrit.libreoffice.org/49107
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Julien Nabet <serval2412 at yahoo.fr>

diff --git a/extensions/source/ole/servprov.cxx b/extensions/source/ole/servprov.cxx
index 4fa08a3a6181..fc1841951762 100644
--- a/extensions/source/ole/servprov.cxx
+++ b/extensions/source/ole/servprov.cxx
@@ -629,12 +629,12 @@ OleServer_Impl::OleServer_Impl( const Reference<XMultiServiceFactory>& smgr):
 
 OleServer_Impl::~OleServer_Impl()
 {
-    while (!m_wrapperList.empty())
+    for (auto const& elem : m_wrapperList)
     {
-        (*m_wrapperList.begin())->deregisterClass();
-        (*m_wrapperList.begin())->Release();
-        m_wrapperList.pop_front();
+        elem->deregisterClass();
+        elem->Release();
     }
+    m_wrapperList.clear();
 }
 
 OUString OleServer_Impl::getImplementationName()
diff --git a/starmath/source/mathmlimport.cxx b/starmath/source/mathmlimport.cxx
index f549cda0ad88..85361823fbf2 100644
--- a/starmath/source/mathmlimport.cxx
+++ b/starmath/source/mathmlimport.cxx
@@ -2696,14 +2696,14 @@ void SmXMLTableContext_Impl::EndElement()
         throw std::range_error("row limit");
     aExpressionArray.resize(nCols*nRows);
     size_t j=0;
-    while ( !aReverseStack.empty() )
+    for (auto & elem : aReverseStack)
     {
-        std::unique_ptr<SmStructureNode> xArray(static_cast<SmStructureNode*>(aReverseStack.front().release()));
-        aReverseStack.pop_front();
+        std::unique_ptr<SmStructureNode> xArray(static_cast<SmStructureNode*>(elem.release()));
         for (size_t i = 0; i < xArray->GetNumSubNodes(); ++i)
             aExpressionArray[j++] = xArray->GetSubNode(i);
         xArray->SetSubNodes(SmNodeArray());
     }
+    aReverseStack.clear();
 
     SmToken aToken;
     aToken.cMathChar = '\0';
diff --git a/sw/source/core/docnode/finalthreadmanager.cxx b/sw/source/core/docnode/finalthreadmanager.cxx
index 4d90b7fa158b..83d0fe3fff13 100644
--- a/sw/source/core/docnode/finalthreadmanager.cxx
+++ b/sw/source/core/docnode/finalthreadmanager.cxx
@@ -337,11 +337,11 @@ void SAL_CALL FinalThreadManager::cancelAllJobs()
             {
                 delete mpCancelJobsThread;
                 mpCancelJobsThread = nullptr;
-                while ( !aThreads.empty() )
+                for (auto const& elem : aThreads)
                 {
-                    aThreads.front()->cancel();
-                    aThreads.pop_front();
+                    elem->cancel();
                 }
+                aThreads.clear();
             }
         }
         else
diff --git a/sw/source/core/text/redlnitr.cxx b/sw/source/core/text/redlnitr.cxx
index da8da1b27e90..e16d7b3b1e34 100644
--- a/sw/source/core/text/redlnitr.cxx
+++ b/sw/source/core/text/redlnitr.cxx
@@ -316,16 +316,15 @@ void SwRedlineItr::Clear_( SwFont* pFnt )
 {
     OSL_ENSURE( bOn, "SwRedlineItr::Clear: Off?" );
     bOn = false;
-    while (!m_Hints.empty())
+    for (auto const& hint : m_Hints)
     {
-        SwTextAttr *pPos = m_Hints.front();
-        m_Hints.pop_front();
         if( pFnt )
-            rAttrHandler.PopAndChg( *pPos, *pFnt );
+            rAttrHandler.PopAndChg( *hint, *pFnt );
         else
-            rAttrHandler.Pop( *pPos );
-        SwTextAttr::Destroy(pPos, const_cast<SwDoc&>(rDoc).GetAttrPool() );
+            rAttrHandler.Pop( *hint );
+        SwTextAttr::Destroy(hint, const_cast<SwDoc&>(rDoc).GetAttrPool() );
     }
+    m_Hints.clear();
 }
 
 sal_Int32 SwRedlineItr::GetNextRedln_( sal_Int32 nNext )
diff --git a/sw/source/filter/html/swhtml.cxx b/sw/source/filter/html/swhtml.cxx
index a02448657dd5..c21a373315ed 100644
--- a/sw/source/filter/html/swhtml.cxx
+++ b/sw/source/filter/html/swhtml.cxx
@@ -2971,13 +2971,11 @@ void SwHTMLParser::SetAttr_( bool bChkEnd, bool bBeforeTable,
             m_aMoveFlyCnts.erase( m_aMoveFlyCnts.begin() + n );
         }
     }
-    while( !aFields.empty() )
+    for (auto const& field : aFields)
     {
-        pAttr = aFields[0];
-
-        pCNd = pAttr->nSttPara.GetNode().GetContentNode();
-        pAttrPam->GetPoint()->nNode = pAttr->nSttPara;
-        pAttrPam->GetPoint()->nContent.Assign( pCNd, pAttr->nSttContent );
+        pCNd = field->nSttPara.GetNode().GetContentNode();
+        pAttrPam->GetPoint()->nNode = field->nSttPara;
+        pAttrPam->GetPoint()->nContent.Assign( pCNd, field->nSttContent );
 
         if( bBeforeTable &&
             pAttrPam->GetPoint()->nNode.GetIndex() == rEndIdx.GetIndex() )
@@ -2989,11 +2987,11 @@ void SwHTMLParser::SetAttr_( bool bChkEnd, bool bBeforeTable,
             pAttrPam->Move( fnMoveBackward );
         }
 
-        m_xDoc->getIDocumentContentOperations().InsertPoolItem( *pAttrPam, *pAttr->pItem );
+        m_xDoc->getIDocumentContentOperations().InsertPoolItem( *pAttrPam, *field->pItem );
 
-        aFields.pop_front();
-        delete pAttr;
+        delete field;
     }
+    aFields.clear();
 }
 
 void SwHTMLParser::NewAttr(const std::shared_ptr<HTMLAttrTable>& rAttrTable, HTMLAttr **ppAttr, const SfxPoolItem& rItem )
diff --git a/vcl/osx/clipboard.cxx b/vcl/osx/clipboard.cxx
index d0c047f54ae8..c31fd9fa491e 100644
--- a/vcl/osx/clipboard.cxx
+++ b/vcl/osx/clipboard.cxx
@@ -264,14 +264,13 @@ void AquaClipboard::fireClipboardChangedEvent()
 
     aGuard.clear();
 
-    while (!listeners.empty())
+    for (auto const& listener : listeners)
     {
-        if (listeners.front().is())
+        if (listener.is())
         {
-            try { listeners.front()->changedContents(aEvent); }
+            try { listener->changedContents(aEvent); }
             catch (RuntimeException&) { }
         }
-        listeners.pop_front();
     }
 }
 
diff --git a/vcl/unx/generic/dtrans/X11_clipboard.cxx b/vcl/unx/generic/dtrans/X11_clipboard.cxx
index ff95772ff321..c4173b138186 100644
--- a/vcl/unx/generic/dtrans/X11_clipboard.cxx
+++ b/vcl/unx/generic/dtrans/X11_clipboard.cxx
@@ -102,11 +102,10 @@ void X11Clipboard::fireChangedContentsEvent()
     aGuard.clear();
 
     ClipboardEvent aEvent( static_cast<OWeakObject*>(this), m_aContents);
-    while( listeners.begin() != listeners.end() )
+    for (auto const& listener : listeners)
     {
-        if( listeners.front().is() )
-            listeners.front()->changedContents(aEvent);
-        listeners.pop_front();
+        if( listener.is() )
+            listener->changedContents(aEvent);
     }
 }
 
diff --git a/vcl/unx/generic/print/printerjob.cxx b/vcl/unx/generic/print/printerjob.cxx
index aa6a6f088d64..884bad2eace5 100644
--- a/vcl/unx/generic/print/printerjob.cxx
+++ b/vcl/unx/generic/print/printerjob.cxx
@@ -825,12 +825,11 @@ void PrinterJob::writeJobPatch( osl::File* pFile, const JobData& rJobData )
     std::sort(patch_order.begin(), patch_order.end());
     patch_order.erase(std::unique(patch_order.begin(), patch_order.end()), patch_order.end());
 
-    while( !patch_order.empty() )
+    for (auto const& elem : patch_order)
     {
         // note: this discards patch files not adhering to the "int" scheme
         // as there won't be a value for them
-        writeFeature( pFile, pKey, pKey->getValue( OUString::number( patch_order.front() ) ), false );
-        patch_order.pop_front();
+        writeFeature( pFile, pKey, pKey->getValue( OUString::number(elem) ), false );
     }
 }
 
diff --git a/vcl/unx/generic/window/salframe.cxx b/vcl/unx/generic/window/salframe.cxx
index 89ea99b6a7f9..c847b6300727 100644
--- a/vcl/unx/generic/window/salframe.cxx
+++ b/vcl/unx/generic/window/salframe.cxx
@@ -106,13 +106,13 @@ static int          nVisibleFloats      = 0;
 static void doReparentPresentationDialogues( SalDisplay const * pDisplay )
 {
     GetGenericUnixSalData()->ErrorTrapPush();
-    while( !aPresentationReparentList.empty() )
+    for (auto const& elem : aPresentationReparentList)
     {
         int x, y;
         ::Window aRoot, aChild;
         unsigned int w, h, bw, d;
         XGetGeometry( pDisplay->GetDisplay(),
-                      aPresentationReparentList.front(),
+                      elem,
                       &aRoot,
                       &x, &y, &w, &h, &bw, &d );
         XTranslateCoordinates( pDisplay->GetDisplay(),
@@ -122,11 +122,11 @@ static void doReparentPresentationDialogues( SalDisplay const * pDisplay )
                                &x, &y,
                                &aChild );
         XReparentWindow( pDisplay->GetDisplay(),
-                         aPresentationReparentList.front(),
+                         elem,
                          aRoot,
                          x, y );
-        aPresentationReparentList.pop_front();
     }
+    aPresentationReparentList.clear();
     if( hPresFocusWindow )
         XSetInputFocus( pDisplay->GetDisplay(), hPresFocusWindow, PointerRoot, CurrentTime );
     XSync( pDisplay->GetDisplay(), False );
diff --git a/writerfilter/source/rtftok/rtfdispatchdestination.cxx b/writerfilter/source/rtftok/rtfdispatchdestination.cxx
index b5b347e6e287..af1a60d947ca 100644
--- a/writerfilter/source/rtftok/rtfdispatchdestination.cxx
+++ b/writerfilter/source/rtftok/rtfdispatchdestination.cxx
@@ -275,16 +275,15 @@ RTFError RTFDocumentImpl::dispatchDestination(RTFKeyword nKeyword)
                         m_aStates.top().pCurrentBuffer = nullptr;
                     bool bCustomMark = false;
                     OUString aCustomMark;
-                    while (!m_aSuperBuffer.empty())
+                    for (auto const& elem : m_aSuperBuffer)
                     {
-                        Buf_t aTuple = m_aSuperBuffer.front();
-                        m_aSuperBuffer.pop_front();
-                        if (std::get<0>(aTuple) == BUFFER_UTEXT)
+                        if (std::get<0>(elem) == BUFFER_UTEXT)
                         {
-                            aCustomMark = std::get<1>(aTuple)->getString();
+                            aCustomMark = std::get<1>(elem)->getString();
                             bCustomMark = true;
                         }
                     }
+                    m_aSuperBuffer.clear();
                     m_aStates.top().eDestination = Destination::FOOTNOTE;
                     Mapper().startCharacterGroup();
                     runProps();


More information about the Libreoffice-commits mailing list