From 5bffa9e375fe294718452ad51e4c5ff017a046b4 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 2 Apr 2019 20:13:16 -0700 Subject: [PATCH] More --- src/hb-map.hh | 5 +++++ src/hb-set.hh | 9 ++++++++- src/hb-vector.hh | 8 ++++---- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/hb-map.hh b/src/hb-map.hh index d760839..9883c0d 100644 --- a/src/hb-map.hh +++ b/src/hb-map.hh @@ -100,6 +100,9 @@ struct hb_hashmap_t void reset () { + if (unlikely (hb_object_is_immutable (this))) + return; + successful = true; clear (); } @@ -185,6 +188,8 @@ struct hb_hashmap_t void clear () { + if (unlikely (hb_object_is_immutable (this))) + return; if (items) + hb_iter (items, mask + 1) | hb_apply ([] (item_t &_) { _.clear (); }) /* TODO make pointer-to-methods invokable. */ diff --git a/src/hb-set.hh b/src/hb-set.hh index 5d48412..34498d9 100644 --- a/src/hb-set.hh +++ b/src/hb-set.hh @@ -227,11 +227,18 @@ struct hb_set_t return true; } - void clear () + void reset () { if (unlikely (hb_object_is_immutable (this))) return; + clear (); successful = true; + } + + void clear () + { + if (unlikely (hb_object_is_immutable (this))) + return; population = 0; page_map.resize (0); pages.resize (0); diff --git a/src/hb-vector.hh b/src/hb-vector.hh index 959df80..e0b7fb0 100644 --- a/src/hb-vector.hh +++ b/src/hb-vector.hh @@ -100,11 +100,11 @@ struct hb_vector_t return *this; } - hb_bytes_t as_bytes () const { return hb_bytes_t ((const char *) arrayZ_, - length * item_size); } + hb_bytes_t as_bytes () const + { return hb_bytes_t ((const char *) arrayZ(), length * item_size); } - bool operator == (const hb_vector_t &o) const { return as_bytes () == o.as_bytes (); } - uint32_t hash () const { return as_bytes ().hash (); } + bool operator == (const hb_vector_t &o) const { return as_array () == o.as_array (); } + uint32_t hash () const { return as_array ().hash (); } const Type * arrayZ () const { return arrayZ_; } Type * arrayZ () { return arrayZ_; } -- 2.7.4