diff --git a/src/hb-set-private.hh b/src/hb-set-private.hh index 8e03d681a..5e30a7e36 100644 --- a/src/hb-set-private.hh +++ b/src/hb-set-private.hh @@ -146,6 +146,9 @@ struct hb_set_t inline void fini (void) { } inline void clear (void) { + if (unlikely (hb_object_is_inert (this))) + return; + in_error = false; memset (elts, 0, sizeof elts); } inline bool is_empty (void) const { @@ -156,23 +159,27 @@ struct hb_set_t } inline void add (hb_codepoint_t g) { + if (unlikely (in_error)) return; if (unlikely (g == SENTINEL)) return; if (unlikely (g > MAX_G)) return; elt (g) |= mask (g); } inline void add_range (hb_codepoint_t a, hb_codepoint_t b) { + if (unlikely (in_error)) return; /* TODO Speedup */ for (unsigned int i = a; i < b + 1; i++) add (i); } inline void del (hb_codepoint_t g) { + if (unlikely (in_error)) return; if (unlikely (g > MAX_G)) return; elt (g) &= ~mask (g); } inline void del_range (hb_codepoint_t a, hb_codepoint_t b) { + if (unlikely (in_error)) return; /* TODO Speedup */ for (unsigned int i = a; i < b + 1; i++) del (i); @@ -202,31 +209,37 @@ struct hb_set_t } inline void set (const hb_set_t *other) { + if (unlikely (in_error)) return; for (unsigned int i = 0; i < ELTS; i++) elts[i] = other->elts[i]; } inline void union_ (const hb_set_t *other) { + if (unlikely (in_error)) return; for (unsigned int i = 0; i < ELTS; i++) elts[i] |= other->elts[i]; } inline void intersect (const hb_set_t *other) { + if (unlikely (in_error)) return; for (unsigned int i = 0; i < ELTS; i++) elts[i] &= other->elts[i]; } inline void subtract (const hb_set_t *other) { + if (unlikely (in_error)) return; for (unsigned int i = 0; i < ELTS; i++) elts[i] &= ~other->elts[i]; } inline void symmetric_difference (const hb_set_t *other) { + if (unlikely (in_error)) return; for (unsigned int i = 0; i < ELTS; i++) elts[i] ^= other->elts[i]; } inline void invert (void) { + if (unlikely (in_error)) return; for (unsigned int i = 0; i < ELTS; i++) elts[i] = ~elts[i]; }