[cache] Use short instead of int if fits

pull/3778/head
Behdad Esfahbod 2 years ago
parent d831e935df
commit 99070a734a
  1. 9
      src/hb-cache.hh

@ -38,11 +38,15 @@ template <unsigned int key_bits=16,
bool thread_safe=true>
struct hb_cache_t
{
using item_t = typename std::conditional<thread_safe, hb_atomic_int_t, int>::type;
using item_t = typename std::conditional<thread_safe,
hb_atomic_int_t,
typename std::conditional<key_bits + value_bits - cache_bits <= 16,
short,
int>::type
>::type;
static_assert ((key_bits >= cache_bits), "");
static_assert ((key_bits + value_bits - cache_bits <= 8 * sizeof (item_t)), "");
static_assert (sizeof (item_t) == sizeof (unsigned int), "");
void init () { clear (); }
void fini () {}
@ -78,7 +82,6 @@ struct hb_cache_t
item_t values[1u<<cache_bits];
};
template <bool thread_safe = true>
using hb_cmap_cache_t = hb_cache_t<21, 16, 8, thread_safe>;

Loading…
Cancel
Save