[Libreoffice-commits] core.git: sdext/source

Julien Nabet serval2412 at yahoo.fr
Sun Dec 10 13:00:02 UTC 2017


 sdext/source/pdfimport/tree/genericelements.cxx |   19 ++++++++-----------
 sdext/source/pdfimport/tree/pdfiprocessor.cxx   |   10 ++++------
 2 files changed, 12 insertions(+), 17 deletions(-)

New commits:
commit 6c42e3961ed29d3b6aa505c46b7d65024055a08e
Author: Julien Nabet <serval2412 at yahoo.fr>
Date:   Sun Dec 10 11:41:38 2017 +0100

    Modernize code in sdext
    
    Change-Id: I2257014cf77b14aba263718b4730744960cc1dc2
    Reviewed-on: https://gerrit.libreoffice.org/46178
    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/sdext/source/pdfimport/tree/genericelements.cxx b/sdext/source/pdfimport/tree/genericelements.cxx
index 6c84d8bd5dd4..ccb2fd53c932 100644
--- a/sdext/source/pdfimport/tree/genericelements.cxx
+++ b/sdext/source/pdfimport/tree/genericelements.cxx
@@ -34,17 +34,14 @@ namespace pdfi
 
 Element::~Element()
 {
-    while( !Children.empty() )
-    {
-        Element* pCurr( Children.front() );
-        delete pCurr;
-        Children.pop_front();
-    }
+    for (auto const& child : Children)
+        delete child;
+    Children.clear();
 }
 
 void Element::applyToChildren( ElementTreeVisitor& rVisitor )
 {
-    for( std::list< Element* >::iterator it = Children.begin(); it != Children.end(); ++it )
+    for( auto it = Children.begin(); it != Children.end(); ++it )
         (*it)->visitedBy( rVisitor, it );
 }
 
@@ -92,8 +89,8 @@ void Element::emitStructure( int nLevel)
 {
     SAL_INFO( "sdext", std::string(nLevel, ' ') << "<" << typeid( *this ).name() << " " << this << "> ("
                 << std::setprecision(1) << x << "," << y << ")+(" << w << "x" << h << ")" );
-    for( std::list< Element* >::iterator it = Children.begin(); it != Children.end(); ++it )
-        (*it)->emitStructure(nLevel+1 );
+    for (auto const& child : Children)
+        child->emitStructure(nLevel+1);
     SAL_INFO( "sdext", std::string(nLevel, ' ') << "</" << typeid( *this ).name() << ">"  );
 }
 #endif
@@ -179,8 +176,8 @@ void PolyPolyElement::emitStructure( int nLevel)
         }
         SAL_WARN( "sdext", "    " << buff.makeStringAndClear() );
     }
-    for( std::list< Element* >::iterator it = Children.begin(); it != Children.end(); ++it )
-        (*it)->emitStructure( nLevel+1 );
+    for (auto const& child : Children)
+        child->emitStructure( nLevel+1 );
     SAL_WARN( "sdext", std::string(nLevel, ' ') << "</" << typeid( *this ).name() << ">");
 }
 #endif
diff --git a/sdext/source/pdfimport/tree/pdfiprocessor.cxx b/sdext/source/pdfimport/tree/pdfiprocessor.cxx
index 79982ded1c4a..fac0e6873638 100644
--- a/sdext/source/pdfimport/tree/pdfiprocessor.cxx
+++ b/sdext/source/pdfimport/tree/pdfiprocessor.cxx
@@ -696,10 +696,9 @@ void PDFIProcessor::sortElements( Element* pEle, bool bDeep )
 
     if( bDeep )
     {
-        for( std::list< Element* >::iterator it = pEle->Children.begin();
-             it != pEle->Children.end(); ++it )
+        for (auto const& child : pEle->Children)
         {
-            sortElements( *it, bDeep );
+            sortElements( child, bDeep );
         }
     }
     // HACK: the stable sort member on std::list that takes a
@@ -716,9 +715,8 @@ void PDFIProcessor::sortElements( Element* pEle, bool bDeep )
         pEle->Children.pop_front();
     }
     std::stable_sort( aChildren.begin(), aChildren.end(), lr_tb_sort );
-    int nChildren = aChildren.size();
-    for( int i = 0; i < nChildren; i++ )
-        pEle->Children.push_back( aChildren[i] );
+    for (auto const& child : aChildren)
+        pEle->Children.push_back(child);
 }
 
 // helper method: get a mirrored string


More information about the Libreoffice-commits mailing list