More
authorBehdad Esfahbod <behdad@behdad.org>
Wed, 3 Apr 2019 03:13:16 +0000 (20:13 -0700)
committerBehdad Esfahbod <behdad@behdad.org>
Wed, 3 Apr 2019 03:13:16 +0000 (20:13 -0700)
src/hb-map.hh
src/hb-set.hh
src/hb-vector.hh

index d760839..9883c0d 100644 (file)
@@ -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. */
index 5d48412..34498d9 100644 (file)
@@ -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);
index 959df80..e0b7fb0 100644 (file)
@@ -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_; }