[subset] Take iterator in ArrayOf serialize

Still not satisfied with how I can enforce iterators only, but
seems to work for now.
This commit is contained in:
Behdad Esfahbod 2018-12-26 22:50:33 -05:00
parent e16884248f
commit 49161d411f
1 changed files with 7 additions and 5 deletions

View File

@ -556,13 +556,15 @@ struct ArrayOf
if (unlikely (!c->extend (*this))) return_trace (false); if (unlikely (!c->extend (*this))) return_trace (false);
return_trace (true); return_trace (true);
} }
template <typename T> template <typename Iter>
bool serialize (hb_serialize_context_t *c, hb_array_t<const T> items) bool serialize (hb_serialize_context_t *c, const hb_iter_t<Iter>& items)
{ {
TRACE_SERIALIZE (this); TRACE_SERIALIZE (this);
if (unlikely (!serialize (c, items.length))) return_trace (false); unsigned count = items.len ();
for (unsigned int i = 0; i < items.length; i++) if (unlikely (!serialize (c, count))) return_trace (false);
hb_assign (arrayZ[i], items[i]); auto iter = items.iter ();
for (unsigned i = 0; i < count; i++, iter++)
hb_assign (arrayZ[i], *iter);
return_trace (true); return_trace (true);
} }