Remove hb_compare_func_t

This commit is contained in:
Behdad Esfahbod 2017-10-29 17:01:47 -06:00
parent 538da7496d
commit 0712e915b4
5 changed files with 28 additions and 19 deletions

View File

@ -63,8 +63,12 @@ struct hb_ot_map_t
unsigned short auto_zwj : 1; unsigned short auto_zwj : 1;
hb_mask_t mask; hb_mask_t mask;
static int cmp (const lookup_map_t *a, const lookup_map_t *b) static int cmp (const void *pa, const void *pb)
{ return a->index < b->index ? -1 : a->index > b->index ? 1 : 0; } {
const lookup_map_t *a = (const lookup_map_t *) pa;
const lookup_map_t *b = (const lookup_map_t *) pb;
return a->index < b->index ? -1 : a->index > b->index ? 1 : 0;
}
}; };
typedef void (*pause_func_t) (const struct hb_ot_shape_plan_t *plan, hb_font_t *font, hb_buffer_t *buffer); typedef void (*pause_func_t) (const struct hb_ot_shape_plan_t *plan, hb_font_t *font, hb_buffer_t *buffer);
@ -210,9 +214,13 @@ struct hb_ot_map_builder_t
unsigned int default_value; /* for non-global features, what should the unset glyphs take */ unsigned int default_value; /* for non-global features, what should the unset glyphs take */
unsigned int stage[2]; /* GSUB/GPOS */ unsigned int stage[2]; /* GSUB/GPOS */
static int cmp (const feature_info_t *a, const feature_info_t *b) static int cmp (const void *pa, const void *pb)
{ return (a->tag != b->tag) ? (a->tag < b->tag ? -1 : 1) : {
(a->seq < b->seq ? -1 : a->seq > b->seq ? 1 : 0); } const feature_info_t *a = (const feature_info_t *) pa;
const feature_info_t *b = (const feature_info_t *) pb;
return (a->tag != b->tag) ? (a->tag < b->tag ? -1 : 1) :
(a->seq < b->seq ? -1 : a->seq > b->seq ? 1 : 0);
}
}; };
struct stage_info_t { struct stage_info_t {

View File

@ -89,7 +89,7 @@ struct name
key.encodingID.set (encoding_id); key.encodingID.set (encoding_id);
key.languageID.set (language_id); key.languageID.set (language_id);
key.nameID.set (name_id); key.nameID.set (name_id);
NameRecord *match = (NameRecord *) bsearch (&key, nameRecord, count, sizeof (nameRecord[0]), (hb_compare_func_t) NameRecord::cmp); NameRecord *match = (NameRecord *) bsearch (&key, nameRecord, count, sizeof (nameRecord[0]), NameRecord::cmp);
if (!match) if (!match)
return 0; return 0;

View File

@ -879,9 +879,11 @@ static const LangTagLong ot_languages_zh[] = {
}; };
static int static int
lang_compare_first_component (const char *a, lang_compare_first_component (const void *pa,
const char *b) const void *pb)
{ {
const char *a = (const char *) pa;
const char *b = (const char *) pb;
unsigned int da, db; unsigned int da, db;
const char *p; const char *p;
@ -972,7 +974,7 @@ hb_ot_tag_from_language (hb_language_t language)
const LangTag *lang_tag; const LangTag *lang_tag;
lang_tag = (LangTag *) bsearch (lang_str, ot_languages, lang_tag = (LangTag *) bsearch (lang_str, ot_languages,
ARRAY_LENGTH (ot_languages), sizeof (LangTag), ARRAY_LENGTH (ot_languages), sizeof (LangTag),
(hb_compare_func_t) lang_compare_first_component); lang_compare_first_component);
if (lang_tag) if (lang_tag)
return lang_tag->tag; return lang_tag->tag;
} }

View File

@ -77,7 +77,7 @@ struct MVAR
const VariationValueRecord *record; const VariationValueRecord *record;
record = (VariationValueRecord *) bsearch (&tag, values, record = (VariationValueRecord *) bsearch (&tag, values,
valueRecordCount, valueRecordSize, valueRecordCount, valueRecordSize,
(hb_compare_func_t) tag_compare); tag_compare);
if (!record) if (!record)
return 0.; return 0.;
@ -85,8 +85,12 @@ struct MVAR
} }
protected: protected:
static inline int tag_compare (const hb_tag_t *a, const Tag *b) static inline int tag_compare (const void *pa, const void *pb)
{ return b->cmp (*a); } {
const hb_tag_t *a = (const hb_tag_t *) pa;
const Tag *b = (const Tag *) pb;
return b->cmp (*a);
}
protected: protected:
FixedVersion<>version; /* Version of the metrics variation table FixedVersion<>version; /* Version of the metrics variation table

View File

@ -372,11 +372,6 @@ _hb_unsigned_int_mul_overflows (unsigned int count, unsigned int size)
} }
/* Type of bsearch() / qsort() compare function */
typedef int (*hb_compare_func_t) (const void *, const void *);
/* arrays and maps */ /* arrays and maps */
@ -480,12 +475,12 @@ struct hb_prealloced_array_t
inline void qsort (void) inline void qsort (void)
{ {
::qsort (array, len, sizeof (Type), (hb_compare_func_t) Type::cmp); ::qsort (array, len, sizeof (Type), Type::cmp);
} }
inline void qsort (unsigned int start, unsigned int end) inline void qsort (unsigned int start, unsigned int end)
{ {
::qsort (array + start, end - start, sizeof (Type), (hb_compare_func_t) Type::cmp); ::qsort (array + start, end - start, sizeof (Type), Type::cmp);
} }
template <typename T> template <typename T>