提交 be7f664f 编写于 作者: B Behdad Esfahbod

Move hb_bytes_t to hb-dsalgs.hh

上级 7a00f7eb
......@@ -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 */
......@@ -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)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册