From 74d0aad22c711b9e2c672afad61570a1ac34ec0a Mon Sep 17 00:00:00 2001 From: Alexei Podtelezhnikov Date: Wed, 1 Oct 2014 23:27:15 -0400 Subject: [PATCH] * src/base/ftcalc.c: Remove miscellaneous type casts. --- ChangeLog | 4 ++++ src/base/ftcalc.c | 22 ++++++++++++---------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9a38f8f87..1468429b0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2014-10-01 Alexei Podtelezhnikov + + * src/base/ftcalc.c: Remove miscellaneous type casts. + 2014-10-01 Alexei Podtelezhnikov [base] Use more common `FT_MSB' implementation with masks. diff --git a/src/base/ftcalc.c b/src/base/ftcalc.c index 3db3f8b06..548137599 100644 --- a/src/base/ftcalc.c +++ b/src/base/ftcalc.c @@ -382,7 +382,7 @@ /* covers the practical range of use. The actual test below is a bit */ /* tighter to avoid the border case overflows. */ /* */ - /* In the case of FT_DivFix, the direct overflow check */ + /* In the case of FT_DivFix, the exact overflow check */ /* */ /* a << 16 <= X - c/2 */ /* */ @@ -419,15 +419,16 @@ FT_Int64 temp, temp2; - ft_multo64( (FT_Int32)a, (FT_Int32)b, &temp ); + ft_multo64( a, b, &temp ); temp2.hi = 0; - temp2.lo = (FT_UInt32)(c >> 1); + temp2.lo = c >> 1; + FT_Add64( &temp, &temp2, &temp ); /* last attempt to ditch long division */ a = temp.hi == 0 ? temp.lo / c - : ft_div64by32( temp.hi, temp.lo, (FT_Int32)c ); + : ft_div64by32( temp.hi, temp.lo, c ); } return ( s < 0 ? -a : a ); @@ -460,11 +461,11 @@ FT_Int64 temp; - ft_multo64( (FT_Int32)a, (FT_Int32)b, &temp ); + ft_multo64( a, b, &temp ); /* last attempt to ditch long division */ a = temp.hi == 0 ? temp.lo / c - : ft_div64by32( temp.hi, temp.lo, (FT_Int32)c ); + : ft_div64by32( temp.hi, temp.lo, c ); } return ( s < 0 ? -a : a ); @@ -603,12 +604,13 @@ FT_Int64 temp, temp2; - temp.hi = (FT_Int32)( a >> 16 ); - temp.lo = (FT_UInt32)a << 16; + temp.hi = a >> 16; + temp.lo = a << 16; temp2.hi = 0; - temp2.lo = (FT_UInt32)( b >> 1 ); + temp2.lo = b >> 1; + FT_Add64( &temp, &temp2, &temp ); - q = (FT_Long)ft_div64by32( temp.hi, temp.lo, (FT_Int32)b ); + q = (FT_Long)ft_div64by32( temp.hi, temp.lo, b ); } return ( s < 0 ? -q : q );