Commit c0a6f20a4b33fefce50dafbf0d7f20aec6b0e724

Alexei Podtelezhnikov 2014-07-16T22:05:56

Replace `ft_highpow2' function. * src/pfr/pfrobjs.c (pfr_face_get_kerning): Use `FT_MSB' instead of `ft_highpow2'. * src/base/ftutil.c, include/internal/ftobjs.h (ft_highpow2): Remove it.

diff --git a/ChangeLog b/ChangeLog
index 04e456f..99c7ba8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2014-07-16  Alexei Podtelezhnikov  <apodtele@gmail.com>
+
+	Replace `ft_highpow2' function.
+
+	* src/pfr/pfrobjs.c (pfr_face_get_kerning): Use `FT_MSB' instead of
+	`ft_highpow2'.
+
+	* src/base/ftutil.c, include/internal/ftobjs.h (ft_highpow2): Remove
+	it.
+
 2014-07-15  Alexei Podtelezhnikov  <apodtele@gmail.com>
 
 	* src/base/ftcalc.c (FT_MSB): Utilize gcc builtins. 
diff --git a/include/internal/ftobjs.h b/include/internal/ftobjs.h
index 701c850..faa37f8 100644
--- a/include/internal/ftobjs.h
+++ b/include/internal/ftobjs.h
@@ -83,14 +83,6 @@ FT_BEGIN_HEADER
 
 
   /*
-   *  Return the highest power of 2 that is <= value; this correspond to
-   *  the highest bit in a given 32-bit value.
-   */
-  FT_BASE( FT_UInt32 )
-  ft_highpow2( FT_UInt32  value );
-
-
-  /*
    *  character classification functions -- since these are used to parse
    *  font files, we must not use those in <ctypes.h> which are
    *  locale-dependent
diff --git a/src/base/ftutil.c b/src/base/ftutil.c
index 879d027..9f37189 100644
--- a/src/base/ftutil.c
+++ b/src/base/ftutil.c
@@ -411,26 +411,4 @@
   }
 
 
-  FT_BASE_DEF( FT_UInt32 )
-  ft_highpow2( FT_UInt32  value )
-  {
-    FT_UInt32  value2;
-
-
-    /*
-     *  We simply clear the lowest bit in each iteration.  When
-     *  we reach 0, we know that the previous value was our result.
-     */
-    for ( ;; )
-    {
-      value2 = value & (value - 1);  /* clear lowest bit */
-      if ( value2 == 0 )
-        break;
-
-      value = value2;
-    }
-    return value;
-  }
-
-
 /* END */
diff --git a/src/pfr/pfrobjs.c b/src/pfr/pfrobjs.c
index 194d2df..abfff2e 100644
--- a/src/pfr/pfrobjs.c
+++ b/src/pfr/pfrobjs.c
@@ -515,7 +515,7 @@
       {
         FT_UInt    count       = item->pair_count;
         FT_UInt    size        = item->pair_size;
-        FT_UInt    power       = (FT_UInt)ft_highpow2( (FT_UInt32)count );
+        FT_UInt    power       = 1 << FT_MSB( count );
         FT_UInt    probe       = power * size;
         FT_UInt    extra       = count - power;
         FT_Byte*   base        = stream->cursor;