Minor, use hb_sorted_array::bsearch where possible

This commit is contained in:
Ebrahim Byagowi 2020-04-19 22:42:57 +04:30
parent fb3acdbcb6
commit 0133cb55e2
3 changed files with 6 additions and 7 deletions

View File

@ -172,7 +172,7 @@ static const hb_aat_feature_mapping_t feature_mappings[] =
const hb_aat_feature_mapping_t *
hb_aat_layout_find_feature_mapping (hb_tag_t tag)
{
return hb_bsearch (tag, feature_mappings, ARRAY_LENGTH (feature_mappings));
return hb_sorted_array (feature_mappings).bsearch (tag);
}
#endif

View File

@ -247,13 +247,13 @@ hb_codepoint_t OT::cff1::lookup_expert_subset_charset_for_sid (hb_codepoint_t gl
hb_codepoint_t OT::cff1::lookup_expert_charset_for_glyph (hb_codepoint_t sid)
{
const auto *pair = hb_bsearch (sid, expert_charset_sid_to_gid, ARRAY_LENGTH (expert_charset_sid_to_gid));
const auto *pair = hb_sorted_array (expert_charset_sid_to_gid).bsearch (sid);
return pair ? pair->gid : 0;
}
hb_codepoint_t OT::cff1::lookup_expert_subset_charset_for_glyph (hb_codepoint_t sid)
{
const auto *pair = hb_bsearch (sid, expert_subset_charset_sid_to_gid, ARRAY_LENGTH (expert_subset_charset_sid_to_gid));
const auto *pair = hb_sorted_array (expert_subset_charset_sid_to_gid).bsearch (sid);
return pair ? pair->gid : 0;
}

View File

@ -222,10 +222,9 @@ static const OS2Range _hb_os2_unicode_ranges[] =
static unsigned int
_hb_ot_os2_get_unicode_range_bit (hb_codepoint_t cp)
{
auto* range = hb_bsearch (cp, _hb_os2_unicode_ranges, ARRAY_LENGTH (_hb_os2_unicode_ranges));
if (range != nullptr)
auto *range = hb_sorted_array (_hb_os2_unicode_ranges).bsearch (cp);
if (unlikely (range == nullptr)) return -1;
return range->bit;
return -1;
}
} /* namespace OT */