[subset/cff1] Micro-optimize code

Let compiler see whether optional argument is present.
This commit is contained in:
Behdad Esfahbod 2023-06-27 16:07:54 -06:00
parent 1cabb65b0a
commit b04721993f
3 changed files with 8 additions and 4 deletions

View file

@ -68,11 +68,15 @@ struct CFFIndex
hb_requires (hb_is_iterable (Iterable))>
bool serialize (hb_serialize_context_t *c,
const Iterable &iterable,
unsigned data_size = (unsigned) -1)
const unsigned *p_data_size = nullptr)
{
TRACE_SERIALIZE (this);
if (data_size == (unsigned) -1)
unsigned data_size;
if (p_data_size)
data_size = *p_data_size;
else
total_size (iterable, &data_size);
auto it = hb_iter (iterable);
if (unlikely (!serialize_header (c, +it, data_size))) return_trace (false);
unsigned char *ret = c->allocate_size<unsigned char> (data_size, false);

View file

@ -831,7 +831,7 @@ OT::cff1::accelerator_subset_t::serialize (hb_serialize_context_t *c,
return false;
auto *cs = c->start_embed<CFF1CharStrings> ();
if (likely (cs->serialize (c, plan.subset_charstrings, data_size)))
if (likely (cs->serialize (c, plan.subset_charstrings, &data_size)))
plan.info.char_strings_link = c->pop_pack (false);
else
{

View file

@ -566,7 +566,7 @@ OT::cff2::accelerator_subset_t::serialize (hb_serialize_context_t *c,
return false;
auto *cs = c->start_embed<CFF2CharStrings> ();
if (likely (cs->serialize (c, plan.subset_charstrings, data_size)))
if (likely (cs->serialize (c, plan.subset_charstrings, &data_size)))
plan.info.char_strings_link = c->pop_pack (false);
else
{