[algs] Fold last other bsearch() in
Now truly have only one bsearch implementation.
This commit is contained in:
parent
53dc8d944f
commit
6a60ca117c
|
@ -291,27 +291,28 @@ struct CmapSubtableFormat4
|
||||||
|
|
||||||
bool get_glyph (hb_codepoint_t codepoint, hb_codepoint_t *glyph) const
|
bool get_glyph (hb_codepoint_t codepoint, hb_codepoint_t *glyph) const
|
||||||
{
|
{
|
||||||
/* Custom two-array bsearch. */
|
struct CustomRange
|
||||||
int min = 0, max = (int) this->segCount - 1;
|
|
||||||
const HBUINT16 *startCount = this->startCount;
|
|
||||||
const HBUINT16 *endCount = this->endCount;
|
|
||||||
unsigned int i;
|
|
||||||
while (min <= max)
|
|
||||||
{
|
{
|
||||||
int mid = ((unsigned int) min + (unsigned int) max) / 2;
|
int cmp (hb_codepoint_t k,
|
||||||
if (codepoint < startCount[mid])
|
unsigned distance) const
|
||||||
max = mid - 1;
|
|
||||||
else if (codepoint > endCount[mid])
|
|
||||||
min = mid + 1;
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
i = mid;
|
if (k > last) return +1;
|
||||||
goto found;
|
if (k < (&last)[distance]) return -1;
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
HBUINT16 last;
|
||||||
return false;
|
};
|
||||||
|
|
||||||
|
const HBUINT16 *found =hb_bsearch (codepoint,
|
||||||
|
this->endCount,
|
||||||
|
this->segCount,
|
||||||
|
2,
|
||||||
|
_hb_cmp_method<hb_codepoint_t, CustomRange, unsigned>,
|
||||||
|
this->segCount + 1);
|
||||||
|
if (!found)
|
||||||
|
return false;
|
||||||
|
unsigned int i = found - endCount;
|
||||||
|
|
||||||
found:
|
|
||||||
hb_codepoint_t gid;
|
hb_codepoint_t gid;
|
||||||
unsigned int rangeOffset = this->idRangeOffset[i];
|
unsigned int rangeOffset = this->idRangeOffset[i];
|
||||||
if (rangeOffset == 0)
|
if (rangeOffset == 0)
|
||||||
|
@ -333,8 +334,10 @@ struct CmapSubtableFormat4
|
||||||
*glyph = gid;
|
*glyph = gid;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
HB_INTERNAL static bool get_glyph_func (const void *obj, hb_codepoint_t codepoint, hb_codepoint_t *glyph)
|
HB_INTERNAL static bool get_glyph_func (const void *obj, hb_codepoint_t codepoint, hb_codepoint_t *glyph)
|
||||||
{ return ((const accelerator_t *) obj)->get_glyph (codepoint, glyph); }
|
{ return ((const accelerator_t *) obj)->get_glyph (codepoint, glyph); }
|
||||||
|
|
||||||
void collect_unicodes (hb_set_t *out) const
|
void collect_unicodes (hb_set_t *out) const
|
||||||
{
|
{
|
||||||
unsigned int count = this->segCount;
|
unsigned int count = this->segCount;
|
||||||
|
|
Loading…
Reference in New Issue