diff options
author | Matteo Casalin <matteo.casalin@yahoo.com> | 2015-08-18 08:15:38 +0200 |
---|---|---|
committer | Matteo Casalin <matteo.casalin@yahoo.com> | 2015-08-21 22:29:41 +0200 |
commit | e28c9ccb014df9616d7a3f3fa1f1b5866d836d94 (patch) | |
tree | aa4cf9a34eed02e24ed86ad2d7589bef2c6e34ab /include | |
parent | Bail-out early and rework loops to use correct unsigned type (diff) | |
download | core-e28c9ccb014df9616d7a3f3fa1f1b5866d836d94.tar.gz core-e28c9ccb014df9616d7a3f3fa1f1b5866d836d94.zip |
There's no need to loop backward, in the end
Change-Id: I2ef533fcc2ac29446a07b98ab34acf1887909c6b
Diffstat (limited to 'include')
-rw-r--r-- | include/vcl/salbtype.hxx | 20 |
1 files changed, 6 insertions, 14 deletions
diff --git a/include/vcl/salbtype.hxx b/include/vcl/salbtype.hxx index fc9445080961..15130a636971 100644 --- a/include/vcl/salbtype.hxx +++ b/include/vcl/salbtype.hxx @@ -550,22 +550,14 @@ inline sal_uInt16 BitmapPalette::GetBestIndex( const BitmapColor& rCol ) const return j; } - nRetIndex = mnCount - 1; - if( nRetIndex ) + sal_uLong nLastErr = rCol.GetColorError( mpBitmapColor[ nRetIndex ] ); + for( sal_uInt16 i = 1; i < mnCount; ++i ) { - sal_uLong nLastErr = rCol.GetColorError( mpBitmapColor[ nRetIndex ] ); - sal_uInt16 i = nRetIndex - 1; - for(;;) + const sal_uLong nActErr = rCol.GetColorError( mpBitmapColor[ i ] ); + if ( nActErr < nLastErr ) { - const sal_uLong nActErr = rCol.GetColorError( mpBitmapColor[ i ] ); - if ( nActErr < nLastErr ) - { - nLastErr = nActErr; - nRetIndex = i; - } - if (!i) - break; - --i; + nLastErr = nActErr; + nRetIndex = i; } } } |