[cff-subset] Simplify INDEX serialize() more

This commit is contained in:
Behdad Esfahbod 2022-12-01 16:09:03 -07:00
parent c4b05878cb
commit a2681c37c1
2 changed files with 6 additions and 17 deletions

View File

@ -72,28 +72,19 @@ struct CFFIndex
return_trace (out); return_trace (out);
} }
template <typename Iterator, template <typename Iterable,
hb_requires (hb_is_iterator (Iterator))> hb_requires (hb_is_iterable (Iterable))>
bool serialize (hb_serialize_context_t *c, bool serialize (hb_serialize_context_t *c,
Iterator it) const Iterable &iterable)
{ {
TRACE_SERIALIZE (this); TRACE_SERIALIZE (this);
serialize_header(c, + it | hb_map ([] (const hb_ubytes_t &_) { return _.length; })); auto it = hb_iter (iterable);
serialize_header(c, + it | hb_map (hb_iter) | hb_map (hb_len));
for (const auto &_ : +it) for (const auto &_ : +it)
_.copy (c); hb_iter (_).copy (c);
return_trace (true); return_trace (true);
} }
bool serialize (hb_serialize_context_t *c,
const str_buff_vec_t &buffArray)
{
auto it =
+ hb_iter (buffArray)
| hb_map ([] (const str_buff_t &_) { return hb_ubytes_t (_.arrayZ, _.length); })
;
return serialize (c, it);
}
template <typename Iterator, template <typename Iterator,
hb_requires (hb_is_iterator (Iterator))> hb_requires (hb_is_iterator (Iterator))>
bool serialize_header (hb_serialize_context_t *c, bool serialize_header (hb_serialize_context_t *c,

View File

@ -617,7 +617,6 @@ struct CFF1StringIndex : CFF1Index
} }
byte_str_array_t bytesArray; byte_str_array_t bytesArray;
bytesArray.init ();
if (!bytesArray.resize (sidmap.get_population ())) if (!bytesArray.resize (sidmap.get_population ()))
return_trace (false); return_trace (false);
for (unsigned int i = 0; i < strings.count; i++) for (unsigned int i = 0; i < strings.count; i++)
@ -628,7 +627,6 @@ struct CFF1StringIndex : CFF1Index
} }
bool result = CFF1Index::serialize (c, bytesArray); bool result = CFF1Index::serialize (c, bytesArray);
bytesArray.fini ();
return_trace (result); return_trace (result);
} }
}; };