[layout] Simplify CoverageFormat2 intersects_coverage()

This commit is contained in:
Behdad Esfahbod 2022-12-03 13:23:26 -07:00
parent 1f4d8ccaed
commit 41a8597f38
1 changed files with 3 additions and 15 deletions

View File

@ -128,21 +128,9 @@ struct CoverageFormat2_4
}
bool intersects_coverage (const hb_set_t *glyphs, unsigned int index) const
{
auto cmp = [] (const void *pk, const void *pr) -> int
{
unsigned index = * (const unsigned *) pk;
const RangeRecord<Types> &range = * (const RangeRecord<Types> *) pr;
if (index < range.value) return -1;
if (index > (unsigned int) range.value + (range.last - range.first)) return +1;
return 0;
};
auto arr = rangeRecord.as_array ();
unsigned idx;
if (hb_bsearch_impl (&idx, index,
arr.arrayZ, arr.length, sizeof (arr[0]),
(int (*)(const void *_key, const void *_item)) cmp))
return arr.arrayZ[idx].intersects (*glyphs);
auto *range = rangeRecord.as_array ().bsearch (index);
if (range)
return range->intersects (*glyphs);
return false;
}