Don't bother sorting, it's a safe font error if the array is not sorted
This commit is contained in:
parent
cc8a4abea6
commit
fd56ae4963
|
@ -724,35 +724,6 @@ struct SortedArrayOf : ArrayOf<Type> {
|
||||||
const Type *p = (const Type *) bsearch (&x, this->array, this->len, sizeof (this->array[0]), Cmp::cmp);
|
const Type *p = (const Type *) bsearch (&x, this->array, this->len, sizeof (this->array[0]), Cmp::cmp);
|
||||||
return p ? p - this->array : -1;
|
return p ? p - this->array : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool sanitize_order (hb_sanitize_context_t *c) {
|
|
||||||
/* Make sure the list is sorted, since we bsearch in it. */
|
|
||||||
unsigned int count = this->len;
|
|
||||||
for (unsigned int i = 1; i < count; i++)
|
|
||||||
if (unlikely (this->array[i].cmp (this->array[i-1]) > 0)) {
|
|
||||||
/* We need to sort the entries. */
|
|
||||||
if (!c->can_edit (this, this->get_size ())) return false;
|
|
||||||
class Cmp {
|
|
||||||
public: static int cmp (const void *p1, const void *p2) {
|
|
||||||
const Type *a = (const Type *) p1;
|
|
||||||
const Type *b = (const Type *) p2;
|
|
||||||
return b->cmp (*a);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
qsort (this->array, this->len, sizeof (this->array[0]), Cmp::cmp);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool sanitize (hb_sanitize_context_t *c) {
|
|
||||||
TRACE_SANITIZE ();
|
|
||||||
return ArrayOf<Type>::sanitize (c) && sanitize_order (c);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool sanitize (hb_sanitize_context_t *c, void *base) {
|
|
||||||
TRACE_SANITIZE ();
|
|
||||||
return ArrayOf<Type>::sanitize (c, base) && sanitize_order (c);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -51,9 +51,6 @@
|
||||||
template <typename Type>
|
template <typename Type>
|
||||||
struct Record
|
struct Record
|
||||||
{
|
{
|
||||||
inline int cmp (const Record &other) const {
|
|
||||||
return cmp (other.tag);
|
|
||||||
}
|
|
||||||
inline int cmp (hb_tag_t b) const {
|
inline int cmp (hb_tag_t b) const {
|
||||||
hb_tag_t a = tag;
|
hb_tag_t a = tag;
|
||||||
return b < a ? -1 : b == a ? 0 : -1;
|
return b < a ? -1 : b == a ? 0 : -1;
|
||||||
|
@ -120,10 +117,6 @@ struct RecordListOf : RecordArrayOf<Type>
|
||||||
|
|
||||||
struct RangeRecord
|
struct RangeRecord
|
||||||
{
|
{
|
||||||
inline int cmp (const RangeRecord &other) const {
|
|
||||||
hb_codepoint_t a = start, b = other.start;
|
|
||||||
return b < a ? -1 : b == a ? 0 : +1;
|
|
||||||
}
|
|
||||||
inline int cmp (hb_codepoint_t g) const {
|
inline int cmp (hb_codepoint_t g) const {
|
||||||
hb_codepoint_t a = start, b = end;
|
hb_codepoint_t a = start, b = end;
|
||||||
return g < a ? -1 : g <= b ? 0 : +1 ;
|
return g < a ? -1 : g <= b ? 0 : +1 ;
|
||||||
|
|
Loading…
Reference in New Issue