[subset/cff1] Speed up sid mapping

Don't need a full inc_bimap.
This commit is contained in:
Behdad Esfahbod 2023-06-06 16:18:44 -06:00
parent 9e80f6b1b6
commit acae5ed25c
2 changed files with 12 additions and 3 deletions

View file

@ -636,7 +636,7 @@ struct Charset
struct CFF1StringIndex : CFF1Index
{
bool serialize (hb_serialize_context_t *c, const CFF1StringIndex &strings,
const hb_inc_bimap_t &sidmap)
const hb_map_t &sidmap)
{
TRACE_SERIALIZE (this);
if (unlikely ((strings.count == 0) || (sidmap.get_population () == 0)))

View file

@ -39,12 +39,20 @@
using namespace CFF;
struct remap_sid_t : hb_inc_bimap_t
struct remap_sid_t : hb_map_t
{
unsigned int add (unsigned int sid)
{
if ((sid != CFF_UNDEF_SID) && !is_std_std (sid))
return offset_sid (hb_inc_bimap_t::add (unoffset_sid (sid)));
{
sid = unoffset_sid (sid);
unsigned v = get (sid);
if (v != HB_MAP_VALUE_INVALID)
return offset_sid (v);
v = next++;
set (sid, v);
return offset_sid (v);
}
else
return sid;
}
@ -62,6 +70,7 @@ struct remap_sid_t : hb_inc_bimap_t
static bool is_std_std (unsigned int sid) { return sid < num_std_strings; }
static unsigned int offset_sid (unsigned int sid) { return sid + num_std_strings; }
static unsigned int unoffset_sid (unsigned int sid) { return sid - num_std_strings; }
unsigned next = 0;
};
struct cff1_sub_table_info_t : cff_sub_table_info_t