Revert back hb_bytes_t.cmp() to the scheme it was
But fix UBSan complaint. There's nothing in hb_bytes_t that guarantees lexical ordering, and ordering by length first is much faster.
This commit is contained in:
parent
534e1d7694
commit
8bb97d2ce1
|
@ -530,14 +530,13 @@ struct hb_bytes_t
|
||||||
|
|
||||||
inline int cmp (const hb_bytes_t &a) const
|
inline int cmp (const hb_bytes_t &a) const
|
||||||
{
|
{
|
||||||
unsigned int l = MIN(a.len, len);
|
if (len != a.len)
|
||||||
if (l) /* glibc's memcmp() args are declared nonnull. Meh. */
|
return (int) a.len - (int) len;
|
||||||
{
|
|
||||||
int r = memcmp (a.arrayZ, arrayZ, l);
|
|
||||||
if (r) return r;
|
|
||||||
}
|
|
||||||
|
|
||||||
return a.len < len ? -1 : a.len > len ? +1 : 0;
|
if (!len)
|
||||||
|
return 0; /* glibc's memcmp() declares args non-NULL, and UBSan doesn't like that. :( */
|
||||||
|
|
||||||
|
return memcmp (a.arrayZ, arrayZ, len);
|
||||||
}
|
}
|
||||||
static inline int cmp (const void *pa, const void *pb)
|
static inline int cmp (const void *pa, const void *pb)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue