[serialize] Use range-based loop

This commit is contained in:
Behdad Esfahbod 2019-05-07 11:05:51 -07:00
parent 0987c4204f
commit 530ddbbc32
1 changed files with 6 additions and 9 deletions

View File

@ -287,26 +287,23 @@ struct hb_serialize_context_t
{ {
assert (!current); assert (!current);
for (auto obj_it = ++hb_iter (packed); obj_it; ++obj_it) for (const object_t *parent : ++hb_iter (packed))
{ {
const object_t &parent = **obj_it; for (const object_t::link_t &link : parent->links)
for (auto link_it = parent.links.iter (); link_it; ++link_it)
{ {
const object_t::link_t &link = *link_it;
const object_t &child = *packed[link.objidx]; const object_t &child = *packed[link.objidx];
//assert (link.bias <= parent.tail - parent.head); //assert (link.bias <= parent->tail - parent->head);
unsigned offset = (child.head - parent.head) - link.bias; unsigned offset = (child.head - parent->head) - link.bias;
if (link.is_wide) if (link.is_wide)
{ {
auto &off = * ((BEInt<uint32_t, 4> *) (parent.head + link.position)); auto &off = * ((BEInt<uint32_t, 4> *) (parent->head + link.position));
assert (0 == off); assert (0 == off);
check_assign (off, offset); check_assign (off, offset);
} }
else else
{ {
auto &off = * ((BEInt<uint16_t, 2> *) (parent.head + link.position)); auto &off = * ((BEInt<uint16_t, 2> *) (parent->head + link.position));
assert (0 == off); assert (0 == off);
check_assign (off, offset); check_assign (off, offset);
} }