[Libreoffice-commits] core.git: vcl/source
Juan Picca
jumapico at gmail.com
Wed Nov 12 04:24:29 PST 2014
vcl/source/outdev/map.cxx | 21 +++++++++------------
1 file changed, 9 insertions(+), 12 deletions(-)
New commits:
commit e52de1ca778d76a60579a656f61013b0dec1fdba
Author: Juan Picca <jumapico at gmail.com>
Date: Tue Nov 4 00:18:02 2014 -0200
Fraction: rewrite condition 'GetDenominator()==-1'
Change-Id: I483024fd0ef3e4e187a143631b2e8bd953fa3a52
Reviewed-on: https://gerrit.libreoffice.org/12240
Reviewed-by: Julien Nabet <serval2412 at yahoo.fr>
Reviewed-by: David Tardon <dtardon at redhat.com>
Tested-by: David Tardon <dtardon at redhat.com>
diff --git a/vcl/source/outdev/map.cxx b/vcl/source/outdev/map.cxx
index fa79b77..b9bd532 100644
--- a/vcl/source/outdev/map.cxx
+++ b/vcl/source/outdev/map.cxx
@@ -45,6 +45,12 @@ ctor fraction once); we could also do this with BigInts
static Fraction ImplMakeFraction( long nN1, long nN2, long nD1, long nD2 )
{
+ if( nD1 == 0 || nD2 == 0 ) //under these bad circumstances the following while loop will be endless
+ {
+ DBG_ASSERT(false,"Invalid parameter for ImplMakeFraction");
+ return Fraction( 1, 1 );
+ }
+
long i = 1;
if ( nN1 < 0 ) { i = -i; nN1 = -nN1; }
@@ -53,17 +59,9 @@ static Fraction ImplMakeFraction( long nN1, long nN2, long nD1, long nD2 )
if ( nD2 < 0 ) { i = -i; nD2 = -nD2; }
// all positive; i sign
- Fraction aF( i*nN1, nD1 );
- aF *= Fraction( nN2, nD2 );
+ Fraction aF = Fraction( i*nN1, nD1 ) * Fraction( nN2, nD2 );
- if( nD1 == 0 || nD2 == 0 ) //under these bad circumstances the following while loop will be endless
- {
- DBG_ASSERT(false,"Invalid parameter for ImplMakeFraction");
- return Fraction( 1, 1 );
- }
-
- while ( aF.GetDenominator() == -1 )
- {
+ while ( !aF.IsValid() ) {
if ( nN1 > nN2 )
nN1 = (nN1 + 1) / 2;
else
@@ -73,8 +71,7 @@ static Fraction ImplMakeFraction( long nN1, long nN2, long nD1, long nD2 )
else
nD2 = (nD2 + 1) / 2;
- aF = Fraction( i*nN1, nD1 );
- aF *= Fraction( nN2, nD2 );
+ aF = Fraction( i*nN1, nD1 ) * Fraction( nN2, nD2 );
}
return aF;
More information about the Libreoffice-commits
mailing list