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:
Behdad Esfahbod 2018-11-10 15:54:33 -05:00
parent 534e1d7694
commit 8bb97d2ce1
1 changed files with 6 additions and 7 deletions

View File

@ -530,14 +530,13 @@ struct hb_bytes_t
inline int cmp (const hb_bytes_t &a) const
{
unsigned int l = MIN(a.len, len);
if (l) /* glibc's memcmp() args are declared nonnull. Meh. */
{
int r = memcmp (a.arrayZ, arrayZ, l);
if (r) return r;
}
if (len != a.len)
return (int) a.len - (int) len;
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)
{