Add hb_set_digest_combiner_t

pull/2/head
Behdad Esfahbod 12 years ago
parent 02e5e58368
commit b40f2c0372
  1. 33
      src/hb-set-private.hh

@ -108,43 +108,50 @@ struct hb_set_digest_lowest_bits_t
extern unsigned long digest_total, digest_yes, digest_yes1, digest_yes2; extern unsigned long digest_total, digest_yes, digest_yes1, digest_yes2;
#endif #endif
struct hb_set_digest_t template <typename head_t, typename tail_t>
struct hb_set_digest_combiner_t
{ {
ASSERT_POD (); ASSERT_POD ();
inline void init (void) { inline void init (void) {
digest1.init (); head.init ();
digest2.init (); tail.init ();
} }
inline void add (hb_codepoint_t g) { inline void add (hb_codepoint_t g) {
digest1.add (g); head.add (g);
digest2.add (g); tail.add (g);
} }
inline void add_range (hb_codepoint_t a, hb_codepoint_t b) { inline void add_range (hb_codepoint_t a, hb_codepoint_t b) {
digest1.add_range (a, b); head.add_range (a, b);
digest2.add_range (a, b); tail.add_range (a, b);
} }
inline bool may_have (hb_codepoint_t g) const { inline bool may_have (hb_codepoint_t g) const {
#ifdef HB_DEBUG_SET_DIGESTS #ifdef HB_DEBUG_SET_DIGESTS
digest_total++; digest_total++;
if (digest1.may_have (g) && digest2.may_have (g)) if (head.may_have (g) && tail.may_have (g))
digest_yes++; digest_yes++;
if (digest1.may_have (g)) if (head.may_have (g))
digest_yes1++; digest_yes1++;
if (digest2.may_have (g)) if (tail.may_have (g))
digest_yes2++; digest_yes2++;
#endif #endif
return digest1.may_have (g) && digest2.may_have (g); return head.may_have (g) && tail.may_have (g);
} }
private: private:
hb_set_digest_common_bits_t digest1; head_t head;
hb_set_digest_lowest_bits_t digest2; tail_t tail;
}; };
typedef hb_set_digest_combiner_t<
hb_set_digest_common_bits_t,
hb_set_digest_lowest_bits_t
>
hb_set_digest_t;
/* TODO Make this faster and memmory efficient. */ /* TODO Make this faster and memmory efficient. */

Loading…
Cancel
Save