summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexei Podtelezhnikov <apodtele@gmail.com>2022-11-07 21:36:32 -0500
committerAlexei Podtelezhnikov <apodtele@gmail.com>2022-11-07 21:36:32 -0500
commite00afdb35b1ec8427fc80eb6949882a24e60f2fa (patch)
tree4f6022050cdc4bb9dbd77ccb97d6b70490fbe97b
parent6139f2b647cd7b432da3877714befbbf7515e607 (diff)
downloadfreetype2-e00afdb35b1ec8427fc80eb6949882a24e60f2fa.tar.gz
* src/pfr/pfrsbit.c (pfr_lookup_bitmap_data): Accelerate the search.
This is mostly for consistency because PFR fonts with bitmap strikes do not seem to exist.
-rw-r--r--src/pfr/pfrsbit.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/pfr/pfrsbit.c b/src/pfr/pfrsbit.c
index d9bf6997a..cc935d603 100644
--- a/src/pfr/pfrsbit.c
+++ b/src/pfr/pfrsbit.c
@@ -282,7 +282,7 @@
FT_ULong* found_offset,
FT_ULong* found_size )
{
- FT_UInt min, max, char_len;
+ FT_UInt min, max, mid, char_len;
FT_Bool two = FT_BOOL( *flags & PFR_BITMAP_2BYTE_CHARCODE );
FT_Byte* buff;
@@ -349,14 +349,14 @@
min = 0;
max = count;
+ mid = min + ( max - min ) / 2;
/* binary search */
while ( min < max )
{
- FT_UInt mid, code;
+ FT_UInt code;
- mid = ( min + max ) >> 1;
buff = base + mid * char_len;
if ( two )
@@ -370,6 +370,11 @@
min = mid + 1;
else
goto Found_It;
+
+ /* reasonable prediction in a continuous block */
+ mid += char_code - code;
+ if ( mid >= max || mid < min )
+ mid = min + ( max - min ) / 2;
}
Fail: