Inline another bsearch()
This commit is contained in:
parent
6fb4ac73f9
commit
db5f7ef189
|
@ -53,8 +53,8 @@ struct hb_ot_map_t
|
|||
unsigned int auto_zwnj : 1;
|
||||
unsigned int auto_zwj : 1;
|
||||
|
||||
static int cmp (const feature_map_t *a, const feature_map_t *b)
|
||||
{ return a->tag < b->tag ? -1 : a->tag > b->tag ? 1 : 0; }
|
||||
inline int cmp (const hb_tag_t *tag_) const
|
||||
{ return *tag_ < tag ? -1 : *tag_ > tag ? 1 : 0; }
|
||||
};
|
||||
|
||||
struct lookup_map_t {
|
||||
|
|
|
@ -488,14 +488,38 @@ struct hb_prealloced_array_t
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
inline Type *bsearch (T *key)
|
||||
inline Type *bsearch (T *x)
|
||||
{
|
||||
return (Type *) ::bsearch (key, array, len, sizeof (Type), (hb_compare_func_t) Type::cmp);
|
||||
int min = 0, max = (int) this->len - 1;
|
||||
while (min <= max)
|
||||
{
|
||||
int mid = (min + max) / 2;
|
||||
int c = this->array[mid].cmp (x);
|
||||
if (c < 0)
|
||||
max = mid - 1;
|
||||
else if (c > 0)
|
||||
min = mid + 1;
|
||||
else
|
||||
return &this->array[mid];
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
template <typename T>
|
||||
inline const Type *bsearch (T *key) const
|
||||
inline const Type *bsearch (T *x) const
|
||||
{
|
||||
return (const Type *) ::bsearch (key, array, len, sizeof (Type), (hb_compare_func_t) Type::cmp);
|
||||
int min = 0, max = (int) this->len - 1;
|
||||
while (min <= max)
|
||||
{
|
||||
int mid = (min + max) / 2;
|
||||
int c = this->array[mid].cmp (x);
|
||||
if (c < 0)
|
||||
max = mid - 1;
|
||||
else if (c > 0)
|
||||
min = mid + 1;
|
||||
else
|
||||
return &this->array[mid];
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
inline void finish (void)
|
||||
|
|
Loading…
Reference in New Issue