freetype-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[freetype2] sqrt_fixed c4073d825 2/2: [psaux] Use `FT_SqrtFixed`.


From: Werner Lemberg
Subject: [freetype2] sqrt_fixed c4073d825 2/2: [psaux] Use `FT_SqrtFixed`.
Date: Tue, 19 Sep 2023 22:30:11 -0400 (EDT)

branch: sqrt_fixed
commit c4073d82517eff48458e166a6edfb0618b221a4d
Author: Alexei Podtelezhnikov <apodtele@gmail.com>
Commit: Alexei Podtelezhnikov <apodtele@gmail.com>

    [psaux] Use `FT_SqrtFixed`.
    
    * src/psaux/cffdecode.c <cff_op_sqrt>: Call `FT_SqrtFixed`.
    * src/psaux/psintrp.c <cf2_escSQRT>: Ditto.
---
 src/psaux/cffdecode.c | 17 ++---------------
 src/psaux/psintrp.c   | 17 +----------------
 2 files changed, 3 insertions(+), 31 deletions(-)

diff --git a/src/psaux/cffdecode.c b/src/psaux/cffdecode.c
index 70173ccb7..40bf276cf 100644
--- a/src/psaux/cffdecode.c
+++ b/src/psaux/cffdecode.c
@@ -1753,22 +1753,9 @@
 
           /* without upper limit the loop below might not finish */
           if ( args[0] > 0x7FFFFFFFL )
-            args[0] = 0xB504F3L;    /* sqrt( 32768.0 ) */
+            args[0] = 0xB504F4L;    /* sqrt( 32768.0044 ) */
           else if ( args[0] > 0 )
-          {
-            FT_Fixed  root = 1 << ( ( 17 + FT_MSB( args[0] ) ) >> 1 );
-            FT_Fixed  new_root;
-
-
-            for (;;)
-            {
-              new_root = ( root + FT_DivFix( args[0], root ) + 1 ) >> 1;
-              if ( new_root == root )
-                break;
-              root = new_root;
-            }
-            args[0] = new_root;
-          }
+            args[0] = (FT_Fixed)FT_SqrtFixed( args[0] );
           else
             args[0] = 0;
           args++;
diff --git a/src/psaux/psintrp.c b/src/psaux/psintrp.c
index fcd49ee0e..b9d5071ee 100644
--- a/src/psaux/psintrp.c
+++ b/src/psaux/psintrp.c
@@ -2276,22 +2276,7 @@
 
                     arg = cf2_stack_popFixed( opStack );
                     if ( arg > 0 )
-                    {
-                      /* initial guess based on the most significant bit */
-                      FT_Fixed  root = 1 << ( ( 17 + FT_MSB( arg ) ) >> 1 );
-                      FT_Fixed  new_root;
-
-
-                      /* Babylonian method */
-                      for (;;)
-                      {
-                        new_root = ( root + FT_DivFix( arg, root ) + 1 ) >> 1;
-                        if ( new_root == root )
-                          break;
-                        root = new_root;
-                      }
-                      arg = new_root;
-                    }
+                      arg = (CF2_F16Dot16)FT_SqrtFixed( arg );
                     else
                       arg = 0;
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]