diff --git a/src/hb-dsalgs.hh b/src/hb-dsalgs.hh index e66f2b4ca..ef030732a 100644 --- a/src/hb-dsalgs.hh +++ b/src/hb-dsalgs.hh @@ -572,6 +572,10 @@ struct hb_array_t return arrayZ[i]; } + template <typename T> inline operator T * (void) const { return arrayZ; } + + inline Type * operator & (void) const { return arrayZ; } + inline unsigned int get_size (void) const { return len * sizeof (Type); } template <typename T> @@ -595,9 +599,15 @@ struct hb_array_t return not_found; } - template <typename T> inline operator T * (void) const { return arrayZ; } - - inline Type * operator & (void) const { return arrayZ; } + inline void qsort (int (*cmp)(const void*, const void*)) + { + ::qsort (arrayZ, len, sizeof (Type), cmp); + } + inline void qsort (unsigned int start = 0, unsigned int end = (unsigned int) -1) + { + end = MIN (end, len); + ::qsort (arrayZ + start, end - start, sizeof (Type), Type::cmp); + } inline hb_array_t<Type> sub_array (unsigned int start_offset, unsigned int seg_count) const { diff --git a/src/hb-vector.hh b/src/hb-vector.hh index a5fa4142b..a8c98d221 100644 --- a/src/hb-vector.hh +++ b/src/hb-vector.hh @@ -221,15 +221,9 @@ struct hb_vector_t } inline void qsort (int (*cmp)(const void*, const void*)) - { - ::qsort (arrayZ(), len, sizeof (Type), cmp); - } - + { as_array ().qsort (cmp); } inline void qsort (unsigned int start = 0, unsigned int end = (unsigned int) -1) - { - end = MIN (end, len); - ::qsort (arrayZ() + start, end - start, sizeof (Type), Type::cmp); - } + { as_array ().qsort (start, end); } template <typename T> inline Type *lsearch (const T &x, Type *not_found = nullptr)