mirror of
https://github.com/harfbuzz/harfbuzz.git
synced 2025-04-14 01:00:37 +00:00
[map] Speed up copy-constructor
This commit is contained in:
parent
e7879d6c55
commit
d46cd93b6a
1 changed files with 23 additions and 1 deletions
|
@ -47,7 +47,29 @@ struct hb_hashmap_t
|
|||
hb_hashmap_t () { init (); }
|
||||
~hb_hashmap_t () { fini (); }
|
||||
|
||||
hb_hashmap_t (const hb_hashmap_t& o) : hb_hashmap_t () { alloc (o.population); hb_copy (o, *this); }
|
||||
hb_hashmap_t (const hb_hashmap_t& o) : hb_hashmap_t ()
|
||||
{
|
||||
if (unlikely (!o.mask)) return;
|
||||
|
||||
if (item_t::is_trivial)
|
||||
{
|
||||
items = (item_t *) hb_malloc (sizeof (item_t) * (o.mask + 1));
|
||||
if (unlikely (!items))
|
||||
{
|
||||
successful = false;
|
||||
return;
|
||||
}
|
||||
population = o.population;
|
||||
occupancy = o.occupancy;
|
||||
mask = o.mask;
|
||||
prime = o.prime;
|
||||
max_chain_length = o.max_chain_length;
|
||||
memcpy (items, o.items, sizeof (item_t) * (mask + 1));
|
||||
return;
|
||||
}
|
||||
|
||||
alloc (o.population); hb_copy (o, *this);
|
||||
}
|
||||
hb_hashmap_t (hb_hashmap_t&& o) : hb_hashmap_t () { hb_swap (*this, o); }
|
||||
hb_hashmap_t& operator= (const hb_hashmap_t& o) { reset (); alloc (o.population); hb_copy (o, *this); return *this; }
|
||||
hb_hashmap_t& operator= (hb_hashmap_t&& o) { hb_swap (*this, o); return *this; }
|
||||
|
|
Loading…
Add table
Reference in a new issue