[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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
diff --git a/ChangeLog b/ChangeLog
index 044c3c2..d53f4df 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,13 +1,22 @@
-2018-09-20 Alexei Podtelezhnikov <apodtele@gmail.com>
+2018-09-23 Alexei Podtelezhnikov <apodtele@gmail.com>
+
+ [bdf] Speed up charmap access.
+
+ This makes FT_Get_Char_Index and FT_Get_Next_Char 4-5 times faster.
- * src/base/ftobjs.c (ft_glyphslot_reset_bimap): Another tweak.
+ * src/bdf/bdfdrivr.c (bdf_cmap_char_{index,next}): Help binary search
+ with continuous prediction.
+
+2018-09-22 Alexei Podtelezhnikov <apodtele@gmail.com>
+
+ * 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 <apodtele@gmail.com>
+2018-09-21 Alexei Podtelezhnikov <apodtele@gmail.com>
- * 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 <bungeman@google.com>
@@ -36,7 +45,7 @@
2018-09-20 Alexei Podtelezhnikov <apodtele@gmail.com>
- * 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.
diff --git a/src/bdf/bdfdrivr.c b/src/bdf/bdfdrivr.c
index fee6110..4a11843 100644
--- a/src/bdf/bdfdrivr.c
+++ b/src/bdf/bdfdrivr.c
@@ -99,13 +99,16 @@ THE SOFTWARE.
min = 0;
max = cmap->num_encodings;
+ mid = ( min + max ) >> 1;
while ( min < max )
{
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 @@ THE SOFTWARE.
max = mid;
else
min = mid + 1;
+
+ /* prediction in a continuous block */
+ mid += charcode - code;
}
return result;
@@ -139,13 +145,16 @@ THE SOFTWARE.
min = 0;
max = cmap->num_encodings;
+ mid = ( min + max ) >> 1;
while ( min < max )
{
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 @@ THE SOFTWARE.
max = mid;
else
min = mid + 1;
+
+ /* prediction in a continuous block */
+ mid += charcode - code;
}
charcode = 0;