diff options
author | Daniel Robertson <danlrobertson89@gmail.com> | 2015-08-29 21:19:05 -0400 |
---|---|---|
committer | Thorsten Behrens <Thorsten.Behrens@CIB.de> | 2015-09-04 23:16:29 +0000 |
commit | cf9fbdb379e2935677a73ced513d7faf855c299c (patch) | |
tree | e5370df3dbd9af4bdb86bdac7026468ab11142d8 /canvas | |
parent | f8c14e81cb63ea077109a4b0147e716cae41ab1b (diff) |
canvas: simplify PageManager::nakedFragment loops
Convert while loops and break statements in PageManager::nakedFragment
into for loops
Change-Id: I671f4eea140f26c2f451d54911d017325084bd08
Reviewed-on: https://gerrit.libreoffice.org/18138
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
Diffstat (limited to 'canvas')
-rw-r--r-- | canvas/source/tools/pagemanager.cxx | 46 |
1 files changed, 16 insertions, 30 deletions
diff --git a/canvas/source/tools/pagemanager.cxx b/canvas/source/tools/pagemanager.cxx index f7faee000287..46c57167a4a5 100644 --- a/canvas/source/tools/pagemanager.cxx +++ b/canvas/source/tools/pagemanager.cxx @@ -85,46 +85,32 @@ namespace canvas // okay, one last chance is left, we try all available // pages again. maybe some other fragment was deleted // and we can exploit the space. - while(!(relocate(pFragment))) + while( !( relocate( pFragment ) ) ) { // no way, we need to free up some space... // TODO(F1): this is a heuristic, could // be designed as a policy. - const FragmentContainer_t::const_iterator aEnd(maFragments.end()); - FragmentContainer_t::const_iterator candidate(maFragments.begin()); - while(candidate != aEnd) + auto aEnd( maFragments.cend() ); + auto aCurrMax( maFragments.end() ); + sal_uInt32 nCurrMaxArea = 0; + for( auto aCurr = maFragments.begin(); aCurr != aEnd; ++aCurr ) { - if(*candidate && !((*candidate)->isNaked())) - break; - ++candidate; - } - - if (candidate != aEnd) - { - const ::basegfx::B2ISize& rSize((*candidate)->getSize()); - sal_uInt32 nMaxArea(rSize.getX()*rSize.getY()); - - FragmentContainer_t::const_iterator it(candidate); - while(it != aEnd) + if( *aCurr && !( ( *aCurr )->isNaked() ) ) { - if (*it && !((*it)->isNaked())) + const ::basegfx::B2ISize& rSize( ( *aCurr )->getSize() ); + sal_uInt32 nArea( rSize.getX() * rSize.getY() ); + + if( nCurrMaxArea < nArea ) { - const ::basegfx::B2ISize& rCandidateSize((*it)->getSize()); - const sal_uInt32 nArea(rCandidateSize.getX()*rCandidateSize.getY()); - if(nArea > nMaxArea) - { - candidate=it; - nMaxArea=nArea; - } + aCurrMax = aCurr; + nCurrMaxArea = nArea; } - - ++it; } - - // this does not erase the candidate, - // but makes it 'naked'... - (*candidate)->free(*candidate); } + // this does not erase the candidate, + // but makes it 'naked'... + if( aCurrMax != aEnd ) + ( *aCurrMax )->free( *aCurrMax ); else break; } |