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

Julien Nabet serval2412 at yahoo.fr
Fri Apr 15 13:04:08 UTC 2016


 svx/source/gallery2/galtheme.cxx |   18 ++++++++----------
 1 file changed, 8 insertions(+), 10 deletions(-)

New commits:
commit e9793bb9792dadfd6c0503bbac260c512451cf06
Author: Julien Nabet <serval2412 at yahoo.fr>
Date:   Fri Apr 15 13:50:36 2016 +0200

    Use an iterator for loop to avoid calling n times std::advance
    
    Change-Id: I8ba45094cc86cdef07ebbfe334c6c42a108f073e
    Reviewed-on: https://gerrit.libreoffice.org/24107
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Julien Nabet <serval2412 at yahoo.fr>

diff --git a/svx/source/gallery2/galtheme.cxx b/svx/source/gallery2/galtheme.cxx
index 05037da..2a2f621 100644
--- a/svx/source/gallery2/galtheme.cxx
+++ b/svx/source/gallery2/galtheme.cxx
@@ -591,19 +591,17 @@ void GalleryTheme::Actualize( const Link<const INetURLObject&, void>& rActualize
         }
 
         // remove all entries with set flag
-        for ( size_t i = 0; i < aObjectList.size(); )
+        GalleryObjectList::const_iterator aEnd = aObjectList.end();
+        for ( GalleryObjectList::iterator it = aObjectList.begin(); it != aEnd ; /* increment is in the body ofloop */)
         {
-            pEntry = aObjectList[ i ];
-            if( pEntry->mbDelete )
+            if( (*it)->mbDelete )
             {
-                Broadcast( GalleryHint( GalleryHintType::CLOSE_OBJECT, GetName(), reinterpret_cast< sal_uIntPtr >( pEntry ) ) );
-                Broadcast( GalleryHint( GalleryHintType::OBJECT_REMOVED, GetName(), reinterpret_cast< sal_uLong >( pEntry ) ) );
-                GalleryObjectList::iterator it = aObjectList.begin();
-                ::std::advance( it, i );
-                aObjectList.erase( it );
-                delete pEntry;
+                Broadcast( GalleryHint( GalleryHintType::CLOSE_OBJECT, GetName(), reinterpret_cast< sal_uIntPtr >( *it ) ) );
+                Broadcast( GalleryHint( GalleryHintType::OBJECT_REMOVED, GetName(), reinterpret_cast< sal_uLong >( *it ) ) );
+                delete *it;
+                it = aObjectList.erase( it );
             }
-            else ++i;
+            else ++it;
         }
 
         // update theme


More information about the Libreoffice-commits mailing list