diff options
author | Matteo Casalin <matteo.casalin@yahoo.com> | 2015-08-17 23:40:28 +0200 |
---|---|---|
committer | Matteo Casalin <matteo.casalin@yahoo.com> | 2015-08-21 22:29:40 +0200 |
commit | 2c3fcc57ea38ad3e4fdd6808343e82321ec0028a (patch) | |
tree | e31fcb4be43a425648b353e3dfe86bcf7f8b0fc2 /include/vcl/salbtype.hxx | |
parent | b6d799b5489918817c1ba7689b305cf21fd654ea (diff) |
Bail-out early and rework loops to use correct unsigned type
Change-Id: If70d600e1253e9d9271282c361e7edf01314eaa1
Diffstat (limited to 'include/vcl/salbtype.hxx')
-rw-r--r-- | include/vcl/salbtype.hxx | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/include/vcl/salbtype.hxx b/include/vcl/salbtype.hxx index 11f263f4e090..fc9445080961 100644 --- a/include/vcl/salbtype.hxx +++ b/include/vcl/salbtype.hxx @@ -544,28 +544,28 @@ inline sal_uInt16 BitmapPalette::GetBestIndex( const BitmapColor& rCol ) const if( mpBitmapColor && mnCount ) { - bool bFound = false; - - for( long j = 0L; ( j < mnCount ) && !bFound; j++ ) + for( sal_uInt16 j = 0; j < mnCount; ++j ) if( rCol == mpBitmapColor[ j ] ) { - nRetIndex = ( (sal_uInt16) j ); - bFound = true; + return j; } - if( !bFound ) + nRetIndex = mnCount - 1; + if( nRetIndex ) { - nRetIndex = mnCount - 1; sal_uLong nLastErr = rCol.GetColorError( mpBitmapColor[ nRetIndex ] ); - - for( long i = nRetIndex - 1; i >= 0L; i-- ) + sal_uInt16 i = nRetIndex - 1; + for(;;) { const sal_uLong nActErr = rCol.GetColorError( mpBitmapColor[ i ] ); if ( nActErr < nLastErr ) { nLastErr = nActErr; - nRetIndex = (sal_uInt16) i; + nRetIndex = i; } + if (!i) + break; + --i; } } } |