Minor refactoring. * src/base/ftcalc.c (FT_MulDiv, FT_MulDiv_No_Round): Updated.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
diff --git a/ChangeLog b/ChangeLog
index 32aa534..4ed20c9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,10 @@
-2014-08-13 Alexei Podtelezhnikov <apodtele@gmail.com>
+2014-08-14 Alexei Podtelezhnikov <apodtele@gmail.com>
+
+ Minor refactoring.
+
+ * src/base/ftcalc.c (FT_MulDiv, FT_MulDiv_No_Round): Updated.
+
+2014-08-14 Alexei Podtelezhnikov <apodtele@gmail.com>
Turn FT_MSB into a macro when using gcc builtins.
diff --git a/src/base/ftcalc.c b/src/base/ftcalc.c
index 9188e2c..27eee57 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 );
}