diff --git a/ChangeLog b/ChangeLog index 32aa534c3..4ed20c936 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,10 @@ -2014-08-13 Alexei Podtelezhnikov +2014-08-14 Alexei Podtelezhnikov + + Minor refactoring. + + * src/base/ftcalc.c (FT_MulDiv, FT_MulDiv_No_Round): Updated. + +2014-08-14 Alexei Podtelezhnikov Turn FT_MSB into a macro when using gcc builtins. diff --git a/src/base/ftcalc.c b/src/base/ftcalc.c index 9188e2c2d..27eee5780 100644 --- a/src/base/ftcalc.c +++ b/src/base/ftcalc.c @@ -400,10 +400,13 @@ s ^= b; b = FT_ABS( b ); s ^= c; c = FT_ABS( c ); - if ( (FT_ULong)a + (FT_ULong)b <= 92681UL - ( c >> 16 ) && c > 0 ) + if ( c == 0 ) + a = 0x7FFFFFFFL; + + else if ( (FT_ULong)a + (FT_ULong)b <= 92681UL - ( c >> 16 ) ) a = ( a * b + ( c >> 1 ) ) / c; - else if ( (FT_Int32)c > 0 ) + else { FT_Int64 temp, temp2; @@ -415,8 +418,6 @@ FT_Add64( &temp, &temp2, &temp ); a = ft_div64by32( temp.hi, temp.lo, (FT_Int32)c ); } - else - a = 0x7FFFFFFFL; return ( s < 0 ? -a : a ); } @@ -437,10 +438,13 @@ s ^= b; b = FT_ABS( b ); s ^= c; c = FT_ABS( c ); - if ( (FT_ULong)a + (FT_ULong)b <= 92681UL && c > 0 ) + if ( c == 0 ) + a = 0x7FFFFFFFL; + + else if ( (FT_ULong)a + (FT_ULong)b <= 92681UL ) a = a * b / c; - else if ( (FT_Int32)c > 0 ) + else { FT_Int64 temp; @@ -448,8 +452,6 @@ ft_multo64( (FT_Int32)a, (FT_Int32)b, &temp ); a = ft_div64by32( temp.hi, temp.lo, (FT_Int32)c ); } - else - a = 0x7FFFFFFFL; return ( s < 0 ? -a : a ); }