This commit is contained in:
Behdad Esfahbod 2019-04-02 20:13:16 -07:00
parent 5b66b033fd
commit 5bffa9e375
3 changed files with 17 additions and 5 deletions

View 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. */

View File

@ -227,11 +227,18 @@ struct hb_set_t
return true;
}
void reset ()
{
if (unlikely (hb_object_is_immutable (this)))
return;
clear ();
successful = true;
}
void clear ()
{
if (unlikely (hb_object_is_immutable (this)))
return;
successful = true;
population = 0;
page_map.resize (0);
pages.resize (0);

View 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_; }