shithub: freetype+ttf2subf

Download patch

ref: 0f122fef346af27ce469fa3e521bbde747fb741c
parent: 793a9ff9f5de353e4e3f7cf0a99b3b1f9b617039
author: Alexei Podtelezhnikov <[email protected]>
date: Sun Sep 23 17:46:26 EDT 2018

[bdf] Speed up charmap access.

This makes FT_Get_Char_Index and FT_Get_Next_Char 4-5 times faster.

* src/bdf/bdfdrivr.c (bdf_cmap_char_{index,next}): Help binary search
with continuous prediction.

git/fs: mount .git/fs: mount/attach disallowed
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,13 +1,22 @@
-2018-09-20  Alexei Podtelezhnikov  <[email protected]>
+2018-09-23  Alexei Podtelezhnikov  <[email protected]>
 
-	* src/base/ftobjs.c (ft_glyphslot_reset_bimap): Another tweak.
+	[bdf] Speed up charmap access.
 
+	This makes FT_Get_Char_Index and FT_Get_Next_Char 4-5 times faster.
+
+	* src/bdf/bdfdrivr.c (bdf_cmap_char_{index,next}): Help binary search
+	with continuous prediction.
+
+2018-09-22  Alexei Podtelezhnikov  <[email protected]>
+
+	* src/base/ftobjs.c (ft_glyphslot_preset_bimap): Another tweak.
+
 	This one should be clearer. When the rounded monochrome bbox collapses
 	we add a pixel that covers most if not all original cbox. 
 
-2018-09-20  Alexei Podtelezhnikov  <[email protected]>
+2018-09-21  Alexei Podtelezhnikov  <[email protected]>
 
-	* src/base/ftobjs.c (ft_glyphslot_reset_bimap): Further tweak.
+	* src/base/ftobjs.c (ft_glyphslot_preset_bimap): Further tweak.
 
 2018-09-21  Ben Wagner  <[email protected]>
 
@@ -36,7 +45,7 @@
 
 2018-09-20  Alexei Podtelezhnikov  <[email protected]>
 
-	* src/base/ftobjs.c (ft_glyphslot_reset_bimap): Tiny rounding tweak.
+	* src/base/ftobjs.c (ft_glyphslot_preset_bimap): Tiny rounding tweak.
 
 	This adds pixels in case a contour goes through the center
 	and they need to be turned on in the b/w rasterizer.
--- a/src/bdf/bdfdrivr.c
+++ b/src/bdf/bdfdrivr.c
@@ -99,6 +99,7 @@
 
     min = 0;
     max = cmap->num_encodings;
+    mid = ( min + max ) >> 1;
 
     while ( min < max )
     {
@@ -105,7 +106,9 @@
       FT_ULong  code;
 
 
-      mid  = ( min + max ) >> 1;
+      if ( mid > max || mid < min )
+        mid = ( min + max ) >> 1;
+
       code = encodings[mid].enc;
 
       if ( charcode == code )
@@ -120,6 +123,9 @@
         max = mid;
       else
         min = mid + 1;
+
+      /* prediction in a continuous block */
+      mid += charcode - code;
     }
 
     return result;
@@ -139,6 +145,7 @@
 
     min = 0;
     max = cmap->num_encodings;
+    mid = ( min + max ) >> 1;
 
     while ( min < max )
     {
@@ -145,7 +152,9 @@
       FT_ULong  code; /* same as BDF_encoding_el.enc */
 
 
-      mid  = ( min + max ) >> 1;
+      if ( mid > max || mid < min )
+        mid = ( min + max ) >> 1;
+
       code = encodings[mid].enc;
 
       if ( charcode == code )
@@ -160,6 +169,9 @@
         max = mid;
       else
         min = mid + 1;
+
+      /* prediction in a continuous block */
+      mid += charcode - code;
     }
 
     charcode = 0;