[algs] Reduce one more bsearch() impl
Ouch, there were three more left. Down one. Two to go.
This commit is contained in:
parent
6f76c325e5
commit
b1dc676eaa
|
@ -1026,18 +1026,15 @@ struct VarSizedBinSearchArrayOf
|
||||||
template <typename T>
|
template <typename T>
|
||||||
const Type *bsearch (const T &key) const
|
const Type *bsearch (const T &key) const
|
||||||
{
|
{
|
||||||
unsigned int size = header.unitSize;
|
unsigned pos;
|
||||||
int min = 0, max = (int) get_length () - 1;
|
return hb_bsearch_impl (&pos,
|
||||||
while (min <= max)
|
key,
|
||||||
{
|
(const void *) bytesZ,
|
||||||
int mid = ((unsigned int) min + (unsigned int) max) / 2;
|
get_length (),
|
||||||
const Type *p = (const Type *) (((const char *) &bytesZ) + (mid * size));
|
header.unitSize,
|
||||||
int c = p->cmp (key);
|
_hb_cmp_method<T, Type>)
|
||||||
if (c < 0) max = mid - 1;
|
? (const Type *) (((const char *) &bytesZ) + (pos * header.unitSize))
|
||||||
else if (c > 0) min = mid + 1;
|
: nullptr;
|
||||||
else return p;
|
|
||||||
}
|
|
||||||
return nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
Loading…
Reference in New Issue