Use bsearch() for large SFNT table directories
This commit is contained in:
parent
b0e33da02d
commit
6c04dcb28d
|
@ -53,6 +53,9 @@ struct TTCHeader;
|
||||||
|
|
||||||
typedef struct TableRecord
|
typedef struct TableRecord
|
||||||
{
|
{
|
||||||
|
int cmp (Tag t) const
|
||||||
|
{ return t.cmp (tag); }
|
||||||
|
|
||||||
inline bool sanitize (hb_sanitize_context_t *c) const
|
inline bool sanitize (hb_sanitize_context_t *c) const
|
||||||
{
|
{
|
||||||
TRACE_SANITIZE (this);
|
TRACE_SANITIZE (this);
|
||||||
|
@ -100,18 +103,12 @@ typedef struct OffsetTable
|
||||||
{
|
{
|
||||||
Tag t;
|
Tag t;
|
||||||
t.set (tag);
|
t.set (tag);
|
||||||
unsigned int count = tables.len;
|
/* Linear-search for small tables to work around fonts with unsorted
|
||||||
/* TODO bsearch() */
|
* table list. */
|
||||||
for (unsigned int i = 0; i < count; i++)
|
int i = tables.len < 64 ? tables.lsearch (t) : tables.bsearch (t);
|
||||||
{
|
if (table_index)
|
||||||
if (t == tables.array[i].tag)
|
*table_index = i == -1 ? Index::NOT_FOUND_INDEX : (unsigned int) i;
|
||||||
{
|
return i != -1;
|
||||||
if (table_index) *table_index = i;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (table_index) *table_index = Index::NOT_FOUND_INDEX;
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
inline const TableRecord& get_table_by_tag (hb_tag_t tag) const
|
inline const TableRecord& get_table_by_tag (hb_tag_t tag) const
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue