Move hb_bytes_t to hb-dsalgs.hh

This commit is contained in:
Behdad Esfahbod 2018-07-10 15:23:08 +02:00
parent 7a00f7eb2e
commit be7f664f72
2 changed files with 34 additions and 37 deletions

View File

@ -53,7 +53,6 @@ hb_bsearch_r (const void *key, const void *base,
}
/* From https://github.com/noporpoise/sort_r */
/* Isaac Turner 29 April 2014 Public Domain */
@ -415,16 +414,6 @@ struct hb_vector_t
}
};
template <typename Type>
struct hb_auto_t : Type
{
hb_auto_t (void) { Type::init (); }
~hb_auto_t (void) { Type::fini (); }
private: /* Hide */
void init (void) {}
void fini (void) {}
};
#define HB_LOCKABLE_SET_INIT {HB_VECTOR_INIT}
template <typename item_t, typename lock_t>
@ -518,4 +507,38 @@ struct hb_lockable_set_t
};
template <typename Type>
struct hb_auto_t : Type
{
hb_auto_t (void) { Type::init (); }
~hb_auto_t (void) { Type::fini (); }
private: /* Hide */
void init (void) {}
void fini (void) {}
};
struct hb_bytes_t
{
inline hb_bytes_t (void) : bytes (nullptr), len (0) {}
inline hb_bytes_t (const char *bytes_, unsigned int len_) : bytes (bytes_), len (len_) {}
inline int cmp (const hb_bytes_t &a) const
{
if (len != a.len)
return (int) a.len - (int) len;
return memcmp (a.bytes, bytes, len);
}
static inline int cmp (const void *pa, const void *pb)
{
hb_bytes_t *a = (hb_bytes_t *) pa;
hb_bytes_t *b = (hb_bytes_t *) pb;
return b->cmp (*a);
}
const char *bytes;
unsigned int len;
};
#endif /* HB_DSALGS_HH */

View File

@ -882,32 +882,6 @@ hb_options (void)
#define VAR 1
/* String type. */
struct hb_bytes_t
{
inline hb_bytes_t (void) : bytes (nullptr), len (0) {}
inline hb_bytes_t (const char *bytes_, unsigned int len_) : bytes (bytes_), len (len_) {}
inline int cmp (const hb_bytes_t &a) const
{
if (len != a.len)
return (int) a.len - (int) len;
return memcmp (a.bytes, bytes, len);
}
static inline int cmp (const void *pa, const void *pb)
{
hb_bytes_t *a = (hb_bytes_t *) pa;
hb_bytes_t *b = (hb_bytes_t *) pb;
return b->cmp (*a);
}
const char *bytes;
unsigned int len;
};
/* fallback for round() */
static inline double
_hb_round (double x)