mirror of
https://github.com/harfbuzz/harfbuzz.git
synced 2025-04-14 17:13:40 +00:00
[subset/cff1] Speed up remap_sids
This commit is contained in:
parent
67b1624727
commit
e0b60bd08d
2 changed files with 14 additions and 9 deletions
|
@ -205,7 +205,7 @@ struct hb_hashmap_t
|
|||
}
|
||||
|
||||
template <typename KK, typename VV>
|
||||
bool set_with_hash (KK&& key, uint32_t hash, VV&& value)
|
||||
bool set_with_hash (KK&& key, uint32_t hash, VV&& value, bool overwrite = true)
|
||||
{
|
||||
if (unlikely (!successful)) return false;
|
||||
if (unlikely ((occupancy + occupancy / 2) >= mask && !resize ())) return false;
|
||||
|
@ -219,7 +219,12 @@ struct hb_hashmap_t
|
|||
{
|
||||
if ((std::is_integral<K>::value || items[i].hash == hash) &&
|
||||
items[i] == key)
|
||||
break;
|
||||
{
|
||||
if (!overwrite)
|
||||
return false;
|
||||
else
|
||||
break;
|
||||
}
|
||||
if (items[i].is_tombstone () && tombstone == (unsigned) -1)
|
||||
tombstone = i;
|
||||
i = (i + ++step) & mask;
|
||||
|
@ -251,9 +256,9 @@ struct hb_hashmap_t
|
|||
}
|
||||
|
||||
template <typename VV>
|
||||
bool set (const K &key, VV&& value) { return set_with_hash (key, hb_hash (key), std::forward<VV> (value)); }
|
||||
bool set (const K &key, VV&& value, bool overwrite = true) { return set_with_hash (key, hb_hash (key), std::forward<VV> (value), overwrite); }
|
||||
template <typename VV>
|
||||
bool set (K &&key, VV&& value) { return set_with_hash (std::move (key), hb_hash (key), std::forward<VV> (value)); }
|
||||
bool set (K &&key, VV&& value, bool overwrite = true) { return set_with_hash (std::move (key), hb_hash (key), std::forward<VV> (value), overwrite); }
|
||||
|
||||
const V& get_with_hash (const K &key, uint32_t hash) const
|
||||
{
|
||||
|
|
|
@ -46,11 +46,11 @@ struct remap_sid_t : hb_map_t
|
|||
if ((sid != CFF_UNDEF_SID) && !is_std_std (sid))
|
||||
{
|
||||
sid = unoffset_sid (sid);
|
||||
unsigned v = get (sid);
|
||||
if (v != HB_MAP_VALUE_INVALID)
|
||||
return offset_sid (v);
|
||||
v = next++;
|
||||
set (sid, v);
|
||||
unsigned v = next;
|
||||
if (set (sid, v, false))
|
||||
next++;
|
||||
else
|
||||
v = get (sid); // already exists
|
||||
return offset_sid (v);
|
||||
}
|
||||
else
|
||||
|
|
Loading…
Add table
Reference in a new issue