[iter] Simplify has() interface implementations

This commit is contained in:
Behdad Esfahbod 2022-11-28 19:42:27 -07:00
parent cba82829ba
commit d2a2670e54
6 changed files with 11 additions and 22 deletions

View File

@ -74,10 +74,8 @@ struct Coverage
} }
/* Has interface. */ /* Has interface. */
static constexpr unsigned SENTINEL = NOT_COVERED; unsigned operator [] (hb_codepoint_t k) const { return get (k); }
typedef unsigned int value_t; bool has (hb_codepoint_t k) const { return (*this)[k] != NOT_COVERED; }
value_t operator [] (hb_codepoint_t k) const { return get (k); }
bool has (hb_codepoint_t k) const { return (*this)[k] != SENTINEL; }
/* Predicate. */ /* Predicate. */
bool operator () (hb_codepoint_t k) const { return has (k); } bool operator () (hb_codepoint_t k) const { return has (k); }

View File

@ -123,10 +123,8 @@ struct hb_bit_set_invertible_t
bool get (hb_codepoint_t g) const { return s.get (g) ^ inverted; } bool get (hb_codepoint_t g) const { return s.get (g) ^ inverted; }
/* Has interface. */ /* Has interface. */
static constexpr bool SENTINEL = false; bool operator [] (hb_codepoint_t k) const { return get (k); }
typedef bool value_t; bool has (hb_codepoint_t k) const { return (*this)[k]; }
value_t operator [] (hb_codepoint_t k) const { return get (k); }
bool has (hb_codepoint_t k) const { return (*this)[k] != SENTINEL; }
/* Predicate. */ /* Predicate. */
bool operator () (hb_codepoint_t k) const { return has (k); } bool operator () (hb_codepoint_t k) const { return has (k); }

View File

@ -330,10 +330,8 @@ struct hb_bit_set_t
} }
/* Has interface. */ /* Has interface. */
static constexpr bool SENTINEL = false; bool operator [] (hb_codepoint_t k) const { return get (k); }
typedef bool value_t; bool has (hb_codepoint_t k) const { return (*this)[k]; }
value_t operator [] (hb_codepoint_t k) const { return get (k); }
bool has (hb_codepoint_t k) const { return (*this)[k] != SENTINEL; }
/* Predicate. */ /* Predicate. */
bool operator () (hb_codepoint_t k) const { return has (k); } bool operator () (hb_codepoint_t k) const { return has (k); }

View File

@ -248,8 +248,7 @@ struct hb_hashmap_t
void del (const K &key) { set_with_hash (key, hb_hash (key), item_t::default_value (), true); } void del (const K &key) { set_with_hash (key, hb_hash (key), item_t::default_value (), true); }
/* Has interface. */ /* Has interface. */
typedef const V& value_t; const V& operator [] (K k) const { return get (k); }
value_t operator [] (K k) const { return get (k); }
template <typename VV=V> template <typename VV=V>
bool has (K key, VV **vp = nullptr) const bool has (K key, VV **vp = nullptr) const
{ {

View File

@ -1999,10 +1999,8 @@ struct ClassDefFormat2_4
struct ClassDef struct ClassDef
{ {
/* Has interface. */ /* Has interface. */
static constexpr unsigned SENTINEL = 0; unsigned operator [] (hb_codepoint_t k) const { return get (k); }
typedef unsigned int value_t; bool has (hb_codepoint_t k) const { return (*this)[k]; }
value_t operator [] (hb_codepoint_t k) const { return get (k); }
bool has (hb_codepoint_t k) const { return (*this)[k] != SENTINEL; }
/* Projection. */ /* Projection. */
hb_codepoint_t operator () (hb_codepoint_t k) const { return get (k); } hb_codepoint_t operator () (hb_codepoint_t k) const { return get (k); }

View File

@ -105,10 +105,8 @@ struct hb_sparseset_t
bool get (hb_codepoint_t g) const { return s.get (g); } bool get (hb_codepoint_t g) const { return s.get (g); }
/* Has interface. */ /* Has interface. */
static constexpr bool SENTINEL = false; bool operator [] (hb_codepoint_t k) const { return get (k); }
typedef bool value_t; bool has (hb_codepoint_t k) const { return (*this)[k]; }
value_t operator [] (hb_codepoint_t k) const { return get (k); }
bool has (hb_codepoint_t k) const { return (*this)[k] != SENTINEL; }
/* Predicate. */ /* Predicate. */
bool operator () (hb_codepoint_t k) const { return has (k); } bool operator () (hb_codepoint_t k) const { return has (k); }