From bddeb2b10ca2f4b4bee6f7eaaf5615875a67111d Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 10 Jul 2018 14:12:37 +0200 Subject: [PATCH] Minor renamings of internal inline functions --- src/hb-buffer.cc | 4 ++-- src/hb-dsalgs.hh | 2 +- src/hb-map-private.hh | 2 +- src/hb-open-type-private.hh | 4 ++-- src/hb-ot-cmap-table.hh | 2 +- src/hb-ot-hdmx-table.hh | 2 +- src/hb-ot-layout-gpos-table.hh | 4 ++-- src/hb-ot-layout-gsub-table.hh | 2 +- src/hb-ot-map.cc | 4 ++-- src/hb-ot-shape.cc | 4 ++-- src/hb-private.hh | 27 ++++++++++++++------------- src/hb-set-private.hh | 6 +++--- src/hb-subset.cc | 2 +- 13 files changed, 33 insertions(+), 32 deletions(-) diff --git a/src/hb-buffer.cc b/src/hb-buffer.cc index 7b95aea43..d04e1e80f 100644 --- a/src/hb-buffer.cc +++ b/src/hb-buffer.cc @@ -124,14 +124,14 @@ hb_buffer_t::enlarge (unsigned int size) hb_glyph_info_t *new_info = nullptr; bool separate_out = out_info != info; - if (unlikely (_hb_unsigned_int_mul_overflows (size, sizeof (info[0])))) + if (unlikely (hb_unsigned_mul_overflows (size, sizeof (info[0])))) goto done; while (size >= new_allocated) new_allocated += (new_allocated >> 1) + 32; static_assert ((sizeof (info[0]) == sizeof (pos[0])), ""); - if (unlikely (_hb_unsigned_int_mul_overflows (new_allocated, sizeof (info[0])))) + if (unlikely (hb_unsigned_mul_overflows (new_allocated, sizeof (info[0])))) goto done; new_pos = (hb_glyph_position_t *) realloc (pos, new_allocated * sizeof (pos[0])); diff --git a/src/hb-dsalgs.hh b/src/hb-dsalgs.hh index 0e44d7cca..ef48fb081 100644 --- a/src/hb-dsalgs.hh +++ b/src/hb-dsalgs.hh @@ -278,7 +278,7 @@ struct hb_vector_t } else { - bool overflows = (new_allocated < allocated) || _hb_unsigned_int_mul_overflows (new_allocated, sizeof (Type)); + bool overflows = (new_allocated < allocated) || hb_unsigned_mul_overflows (new_allocated, sizeof (Type)); if (likely (!overflows)) new_array = (Type *) realloc (arrayZ, new_allocated * sizeof (Type)); } diff --git a/src/hb-map-private.hh b/src/hb-map-private.hh index d3d4ddeda..c4f2fc7da 100644 --- a/src/hb-map-private.hh +++ b/src/hb-map-private.hh @@ -89,7 +89,7 @@ struct hb_map_t { if (unlikely (!successful)) return false; - unsigned int power = _hb_bit_storage (population * 2 + 8); + unsigned int power = hb_bit_storage (population * 2 + 8); unsigned int new_size = 1u << power; item_t *new_items = (item_t *) malloc ((size_t) new_size * sizeof (item_t)); if (unlikely (!new_items)) diff --git a/src/hb-open-type-private.hh b/src/hb-open-type-private.hh index 9a4835b89..59b8cc02b 100644 --- a/src/hb-open-type-private.hh +++ b/src/hb-open-type-private.hh @@ -230,7 +230,7 @@ struct hb_sanitize_context_t : inline bool check_array (const void *base, unsigned int record_size, unsigned int len) const { const char *p = (const char *) base; - bool overflows = _hb_unsigned_int_mul_overflows (len, record_size); + bool overflows = hb_unsigned_mul_overflows (len, record_size); unsigned int array_size = record_size * len; bool ok = !overflows && this->check_range (base, array_size); @@ -1178,7 +1178,7 @@ struct BinSearchHeader { len.set (v); assert (len == v); - entrySelector.set (MAX (1u, _hb_bit_storage (v)) - 1); + entrySelector.set (MAX (1u, hb_bit_storage (v)) - 1); searchRange.set (16 * (1u << entrySelector)); rangeShift.set (v * 16 > searchRange ? 16 * v - searchRange diff --git a/src/hb-ot-cmap-table.hh b/src/hb-ot-cmap-table.hh index c1903f6e3..0ea37209a 100644 --- a/src/hb-ot-cmap-table.hh +++ b/src/hb-ot-cmap-table.hh @@ -89,7 +89,7 @@ struct CmapSubtableFormat4 this->length.set (get_sub_table_size (segments)); this->segCountX2.set (segments.len * 2); - this->entrySelector.set (MAX (1u, _hb_bit_storage (segments.len)) - 1); + this->entrySelector.set (MAX (1u, hb_bit_storage (segments.len)) - 1); this->searchRange.set (2 * (1u << this->entrySelector)); this->rangeShift.set (segments.len * 2 > this->searchRange ? 2 * segments.len - this->searchRange diff --git a/src/hb-ot-hdmx-table.hh b/src/hb-ot-hdmx-table.hh index d406e3e21..0951871ce 100644 --- a/src/hb-ot-hdmx-table.hh +++ b/src/hb-ot-hdmx-table.hh @@ -199,7 +199,7 @@ struct hdmx { TRACE_SANITIZE (this); return_trace (c->check_struct (this) && version == 0 && - !_hb_unsigned_int_mul_overflows (num_records, size_device_record) && + !hb_unsigned_mul_overflows (num_records, size_device_record) && size_device_record >= DeviceRecord::min_size && c->check_range (this, get_size())); } diff --git a/src/hb-ot-layout-gpos-table.hh b/src/hb-ot-layout-gpos-table.hh index 182c8d909..b52c0144f 100644 --- a/src/hb-ot-layout-gpos-table.hh +++ b/src/hb-ot-layout-gpos-table.hh @@ -99,7 +99,7 @@ struct ValueFormat : HBUINT16 #endif inline unsigned int get_len (void) const - { return _hb_popcount ((unsigned int) *this); } + { return hb_popcount ((unsigned int) *this); } inline unsigned int get_size (void) const { return get_len () * Value::static_size; } @@ -374,7 +374,7 @@ struct AnchorMatrix { TRACE_SANITIZE (this); if (!c->check_struct (this)) return_trace (false); - if (unlikely (_hb_unsigned_int_mul_overflows (rows, cols))) return_trace (false); + if (unlikely (hb_unsigned_mul_overflows (rows, cols))) return_trace (false); unsigned int count = rows * cols; if (!c->check_array (matrixZ, matrixZ[0].static_size, count)) return_trace (false); for (unsigned int i = 0; i < count; i++) diff --git a/src/hb-ot-layout-gsub-table.hh b/src/hb-ot-layout-gsub-table.hh index bd72fe6bf..91b898b63 100644 --- a/src/hb-ot-layout-gsub-table.hh +++ b/src/hb-ot-layout-gsub-table.hh @@ -511,7 +511,7 @@ struct AlternateSubstFormat1 hb_mask_t lookup_mask = c->lookup_mask; /* Note: This breaks badly if two features enabled this lookup together. */ - unsigned int shift = _hb_ctz (lookup_mask); + unsigned int shift = hb_ctz (lookup_mask); unsigned int alt_index = ((lookup_mask & glyph_mask) >> shift); if (unlikely (alt_index > alt_set.len || alt_index == 0)) return_trace (false); diff --git a/src/hb-ot-map.cc b/src/hb-ot-map.cc index 46bf2db0c..f26cac9b1 100644 --- a/src/hb-ot-map.cc +++ b/src/hb-ot-map.cc @@ -145,7 +145,7 @@ hb_ot_map_builder_t::compile (hb_ot_map_t &m, { static_assert ((!(HB_GLYPH_FLAG_DEFINED & (HB_GLYPH_FLAG_DEFINED + 1))), ""); unsigned int global_bit_mask = HB_GLYPH_FLAG_DEFINED + 1; - unsigned int global_bit_shift = _hb_popcount (HB_GLYPH_FLAG_DEFINED); + unsigned int global_bit_shift = hb_popcount (HB_GLYPH_FLAG_DEFINED); m.global_mask = global_bit_mask; @@ -209,7 +209,7 @@ hb_ot_map_builder_t::compile (hb_ot_map_t &m, bits_needed = 0; else /* Limit to 8 bits per feature. */ - bits_needed = MIN(8u, _hb_bit_storage (info->max_value)); + bits_needed = MIN(8u, hb_bit_storage (info->max_value)); if (!info->max_value || next_bit + bits_needed > 8 * sizeof (hb_mask_t)) continue; /* Feature disabled, or not enough bits. */ diff --git a/src/hb-ot-shape.cc b/src/hb-ot-shape.cc index 36e0bf9c3..1189b2075 100644 --- a/src/hb-ot-shape.cc +++ b/src/hb-ot-shape.cc @@ -829,12 +829,12 @@ hb_ot_shape_internal (hb_ot_shape_context_t *c) { c->buffer->deallocate_var_all (); c->buffer->scratch_flags = HB_BUFFER_SCRATCH_FLAG_DEFAULT; - if (likely (!_hb_unsigned_int_mul_overflows (c->buffer->len, HB_BUFFER_MAX_LEN_FACTOR))) + if (likely (!hb_unsigned_mul_overflows (c->buffer->len, HB_BUFFER_MAX_LEN_FACTOR))) { c->buffer->max_len = MAX (c->buffer->len * HB_BUFFER_MAX_LEN_FACTOR, (unsigned) HB_BUFFER_MAX_LEN_MIN); } - if (likely (!_hb_unsigned_int_mul_overflows (c->buffer->len, HB_BUFFER_MAX_OPS_FACTOR))) + if (likely (!hb_unsigned_mul_overflows (c->buffer->len, HB_BUFFER_MAX_OPS_FACTOR))) { c->buffer->max_ops = MAX (c->buffer->len * HB_BUFFER_MAX_OPS_FACTOR, (unsigned) HB_BUFFER_MAX_OPS_MIN); diff --git a/src/hb-private.hh b/src/hb-private.hh index 65d4bae2f..fa9a1aee2 100644 --- a/src/hb-private.hh +++ b/src/hb-private.hh @@ -362,7 +362,7 @@ typedef const struct _hb_void_t *hb_void_t; /* Return the number of 1 bits in v. */ template static inline HB_CONST_FUNC unsigned int -_hb_popcount (T v) +hb_popcount (T v) { #if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) && defined(__OPTIMIZE__) if (sizeof (T) <= sizeof (unsigned int)) @@ -387,13 +387,13 @@ _hb_popcount (T v) if (sizeof (T) == 8) { unsigned int shift = 32; - return _hb_popcount ((uint32_t) v) + _hb_popcount ((uint32_t) (v >> shift)); + return hb_popcount ((uint32_t) v) + hb_popcount ((uint32_t) (v >> shift)); } if (sizeof (T) == 16) { unsigned int shift = 64; - return _hb_popcount ((uint64_t) v) + _hb_popcount ((uint64_t) (v >> shift)); + return hb_popcount ((uint64_t) v) + hb_popcount ((uint64_t) (v >> shift)); } assert (0); @@ -403,7 +403,7 @@ _hb_popcount (T v) /* Returns the number of bits needed to store number */ template static inline HB_CONST_FUNC unsigned int -_hb_bit_storage (T v) +hb_bit_storage (T v) { if (unlikely (!v)) return 0; @@ -466,8 +466,8 @@ _hb_bit_storage (T v) if (sizeof (T) == 16) { unsigned int shift = 64; - return (v >> shift) ? _hb_bit_storage ((uint64_t) (v >> shift)) + shift : - _hb_bit_storage ((uint64_t) v); + return (v >> shift) ? hb_bit_storage ((uint64_t) (v >> shift)) + shift : + hb_bit_storage ((uint64_t) v); } assert (0); @@ -477,7 +477,7 @@ _hb_bit_storage (T v) /* Returns the number of zero bits in the least significant side of v */ template static inline HB_CONST_FUNC unsigned int -_hb_ctz (T v) +hb_ctz (T v) { if (unlikely (!v)) return 0; @@ -539,8 +539,8 @@ _hb_ctz (T v) if (sizeof (T) == 16) { unsigned int shift = 64; - return (uint64_t) v ? _hb_bit_storage ((uint64_t) v) : - _hb_bit_storage ((uint64_t) v >> shift) + shift; + return (uint64_t) v ? hb_bit_storage ((uint64_t) v) : + hb_bit_storage ((uint64_t) v >> shift) + shift; } assert (0); @@ -548,18 +548,19 @@ _hb_ctz (T v) } static inline bool -_hb_unsigned_int_mul_overflows (unsigned int count, unsigned int size) +hb_unsigned_mul_overflows (unsigned int count, unsigned int size) { return (size > 0) && (count >= ((unsigned int) -1) / size); } static inline unsigned int -_hb_ceil_to_4 (unsigned int v) +hb_ceil_to_4 (unsigned int v) { return ((v - 1) | 3) + 1; } -static inline bool _hb_ispow2 (unsigned int v) +static inline bool +hb_ispow2 (unsigned int v) { return 0 == (v & (v - 1)); } @@ -925,7 +926,7 @@ _hb_round (double x) static inline int _hb_memalign(void **memptr, size_t alignment, size_t size) { - if (unlikely (!_hb_ispow2 (alignment) || + if (unlikely (!hb_ispow2 (alignment) || !alignment || 0 != (alignment & (sizeof (void *) - 1)))) return EINVAL; diff --git a/src/hb-set-private.hh b/src/hb-set-private.hh index 6841189ec..bdaf3f1a2 100644 --- a/src/hb-set-private.hh +++ b/src/hb-set-private.hh @@ -94,7 +94,7 @@ struct hb_set_t { unsigned int pop = 0; for (unsigned int i = 0; i < len (); i++) - pop += _hb_popcount (v[i]); + pop += hb_popcount (v[i]); return pop; } @@ -161,8 +161,8 @@ struct hb_set_t static const unsigned int PAGE_BITS = 512; static_assert ((PAGE_BITS & ((PAGE_BITS) - 1)) == 0, ""); - static inline unsigned int elt_get_min (const elt_t &elt) { return _hb_ctz (elt); } - static inline unsigned int elt_get_max (const elt_t &elt) { return _hb_bit_storage (elt) - 1; } + static inline unsigned int elt_get_min (const elt_t &elt) { return hb_ctz (elt); } + static inline unsigned int elt_get_max (const elt_t &elt) { return hb_bit_storage (elt) - 1; } typedef hb_vector_size_t vector_t; diff --git a/src/hb-subset.cc b/src/hb-subset.cc index b97c7633e..e86063418 100644 --- a/src/hb-subset.cc +++ b/src/hb-subset.cc @@ -154,7 +154,7 @@ _hb_subset_face_data_reference_blob (hb_subset_face_data_t *data) unsigned int face_length = table_count * 16 + 12; for (unsigned int i = 0; i < table_count; i++) - face_length += _hb_ceil_to_4 (hb_blob_get_length (data->tables.arrayZ[i].blob)); + face_length += hb_ceil_to_4 (hb_blob_get_length (data->tables.arrayZ[i].blob)); char *buf = (char *) malloc (face_length); if (unlikely (!buf))