diff --git a/src/hb-algs.hh b/src/hb-algs.hh index be3ef08fa..b01380e63 100644 --- a/src/hb-algs.hh +++ b/src/hb-algs.hh @@ -1450,27 +1450,7 @@ hb_qsort (void *base, size_t nel, size_t width, sort_r_simple (base, nel, width, compar); } -static inline void -hb_qsort (void *base, size_t nel, size_t width, - int (*compar)(const void *_a, const void *_b)) -{ -#if defined(__OPTIMIZE_SIZE__) && !defined(HB_USE_INTERNAL_QSORT) - qsort (base, nel, width, compar); -#else - sort_r_simple (base, nel, width, compar); -#endif -} -static inline void -hb_qsort (void *base, size_t nel, size_t width, - int (*compar)(const void *_a, const void *_b, void *_arg), - void *arg) -{ - hb_qsort (base, nel, width, - [compar, arg] (const void *a, const void *b) { - return compar (a, b, arg); - }); -} template static inline void diff --git a/src/hb-array.hh b/src/hb-array.hh index 8c7111874..155ac797f 100644 --- a/src/hb-array.hh +++ b/src/hb-array.hh @@ -219,12 +219,6 @@ struct hb_array_t : hb_iter_with_fallback_t, Type&> return false; } - hb_sorted_array_t qsort (int (*cmp_)(const void*, const void*)) - { - if (likely (length)) - hb_qsort (arrayZ, length, this->get_item_size (), cmp_); - return hb_sorted_array_t (*this); - } template hb_sorted_array_t qsort (Compar compar) { @@ -234,10 +228,7 @@ struct hb_array_t : hb_iter_with_fallback_t, Type&> } hb_sorted_array_t qsort () { - //static_assert (hb_enable_if (hb_is_trivially_copy_assignable(Type)), ""); - if (likely (length)) - hb_qsort (arrayZ, length, this->get_item_size (), Type::cmp); - return hb_sorted_array_t (*this); + return qsort ((int(*)(const void*, const void*)) Type::cmp); } /* diff --git a/src/hb-cairo-utils.cc b/src/hb-cairo-utils.cc index 10db1d5cb..b7a7a853f 100644 --- a/src/hb-cairo-utils.cc +++ b/src/hb-cairo-utils.cc @@ -229,9 +229,8 @@ _hb_cairo_reduce_anchors (float x0, float y0, *yy1 = y1 - k * q2y; } -static int -_hb_cairo_cmp_color_stop (const void *p1, - const void *p2) +static inline int +_hb_cairo_cmp_color_stop (const void *p1, const void *p2) { const hb_color_stop_t *c1 = (const hb_color_stop_t *) p1; const hb_color_stop_t *c2 = (const hb_color_stop_t *) p2; diff --git a/src/hb-ot-post-table.hh b/src/hb-ot-post-table.hh index 2d8acd825..d6766763d 100644 --- a/src/hb-ot-post-table.hh +++ b/src/hb-ot-post-table.hh @@ -194,7 +194,12 @@ struct post for (unsigned int i = 0; i < count; i++) gids[i] = i; - hb_qsort (gids, count, sizeof (gids[0]), cmp_gids, (void *) this); + hb_qsort (gids, count, sizeof (gids[0]), + [this] (const void *pa, const void *pb) -> int { + uint16_t a = * (const uint16_t *) pa; + uint16_t b = * (const uint16_t *) pb; + return find_glyph_name (b).cmp (find_glyph_name (a)); + }); if (unlikely (!gids_sorted_by_name.cmpexch (nullptr, gids))) { @@ -235,14 +240,6 @@ struct post return 0; } - static int cmp_gids (const void *pa, const void *pb, void *arg) - { - const accelerator_t *thiz = (const accelerator_t *) arg; - uint16_t a = * (const uint16_t *) pa; - uint16_t b = * (const uint16_t *) pb; - return thiz->find_glyph_name (b).cmp (thiz->find_glyph_name (a)); - } - static int cmp_key (const void *pk, const void *po, void *arg) { const accelerator_t *thiz = (const accelerator_t *) arg; diff --git a/src/hb-raster-paint.cc b/src/hb-raster-paint.cc index 585ec1d66..004c43e1a 100644 --- a/src/hb-raster-paint.cc +++ b/src/hb-raster-paint.cc @@ -869,7 +869,7 @@ hb_raster_paint_image (hb_paint_funcs_t *pfuncs HB_UNUSED, #define GRADIENT_LUT_SIZE 256 #define GRADIENT_LUT_MIN_PIXELS (64u * 64u) -static int +static inline int cmp_color_stop (const void *p1, const void *p2) { const hb_color_stop_t *c1 = (const hb_color_stop_t *) p1; diff --git a/src/hb-vector.hh b/src/hb-vector.hh index 0a028b8df..27e13829b 100644 --- a/src/hb-vector.hh +++ b/src/hb-vector.hh @@ -705,13 +705,11 @@ struct hb_vector_t /* Sorting API. */ - void qsort (int (*cmp)(const void*, const void*)) - { as_array ().qsort (cmp); } template void qsort (Compar compar) { as_array ().qsort (compar); } void qsort () - { as_array ().qsort (Type::cmp); } + { as_array ().qsort (); } /* Unsorted search API. */ template