Commit 0c817334b708a83425ce5b86448c4d6a26ebbc76

Alexei Podtelezhnikov 2023-08-25T17:57:47

* src/base/ftcalc.c (FT_MulAddFix): Simplify 32-bit rounding.

diff --git a/src/base/ftcalc.c b/src/base/ftcalc.c
index 9e87abd..c5bc7e3 100644
--- a/src/base/ftcalc.c
+++ b/src/base/ftcalc.c
@@ -1070,9 +1070,6 @@
   {
     FT_UInt   i;
     FT_Int64  temp;
-#ifndef FT_INT64
-    FT_Int64  halfUnit;
-#endif
 
 
 #ifdef FT_INT64
@@ -1117,13 +1114,10 @@
       FT_Add64( &temp, &multResult, &temp );
     }
 
-    /* Round value. */
-    halfUnit.hi = 0;
-    halfUnit.lo = 0x8000;
-    FT_Add64( &temp, &halfUnit, &temp );
+    /* Shift and round value. */
+    return (FT_Int32)( ( ( temp.hi << 16 ) | ( temp.lo >> 16 ) )
+                                     + ( 1 & ( temp.lo >> 15 ) ) );
 
-    return (FT_Int32)( ( (FT_Int32)( temp.hi & 0xFFFF ) << 16 ) |
-                                   ( temp.lo >> 16 )            );
 
 #endif /* !FT_INT64 */