From e9793bb9792dadfd6c0503bbac260c512451cf06 Mon Sep 17 00:00:00 2001 From: Julien Nabet Date: Fri, 15 Apr 2016 13:50:36 +0200 Subject: 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 Reviewed-by: Julien Nabet --- svx/source/gallery2/galtheme.cxx | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'svx/source/gallery2') diff --git a/svx/source/gallery2/galtheme.cxx b/svx/source/gallery2/galtheme.cxx index 05037da5ee5e..2a2f6218d480 100644 --- a/svx/source/gallery2/galtheme.cxx +++ b/svx/source/gallery2/galtheme.cxx @@ -591,19 +591,17 @@ void GalleryTheme::Actualize( const Link& 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 -- cgit