From be7f664f723fb4e7bcf15c1c2b7c6bec46f90393 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 10 Jul 2018 15:23:08 +0200 Subject: [PATCH] Move hb_bytes_t to hb-dsalgs.hh --- src/hb-dsalgs.hh | 45 ++++++++++++++++++++++++++++++++++----------- src/hb-private.hh | 26 -------------------------- 2 files changed, 34 insertions(+), 37 deletions(-) diff --git a/src/hb-dsalgs.hh b/src/hb-dsalgs.hh index e8fa9b3c7..4eceeb2fb 100644 --- a/src/hb-dsalgs.hh +++ b/src/hb-dsalgs.hh @@ -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 -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 @@ -518,4 +507,38 @@ struct hb_lockable_set_t }; +template +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 */ diff --git a/src/hb-private.hh b/src/hb-private.hh index 4201fe6ef..aa4d017c9 100644 --- a/src/hb-private.hh +++ b/src/hb-private.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)