[serialize] use for each as #resolve_links, format

This commit is contained in:
Ebrahim Byagowi 2019-09-24 12:06:28 +03:30 committed by GitHub
parent 512551f276
commit 22b6c6a5c7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 15 deletions

View File

@ -91,9 +91,7 @@ struct hb_serialize_context_t
void fini ()
{
++ hb_iter (packed)
| hb_apply ([] (object_t *_) { _->fini (); })
;
for (object_t *_ : ++hb_iter (packed)) _->fini ();
packed.fini ();
this->packed_map.fini ();
@ -292,7 +290,6 @@ struct hb_serialize_context_t
assert (packed.length > 1);
for (const object_t* parent : ++hb_iter (packed))
{
for (const object_t::link_t &link : parent->links)
{
const object_t* child = packed[link.objidx];
@ -312,7 +309,6 @@ struct hb_serialize_context_t
check_assign (off, offset);
}
}
}
}
unsigned int length () const { return this->head - current->head; }
@ -354,9 +350,7 @@ struct hb_serialize_context_t
template <typename Type>
Type *allocate_min ()
{
return this->allocate_size<Type> (Type::min_size);
}
{ return this->allocate_size<Type> (Type::min_size); }
template <typename Type>
Type *embed (const Type *obj)
@ -428,14 +422,12 @@ struct hb_serialize_context_t
/* Copy both items from head side and tail side... */
unsigned int len = (this->head - this->start)
+ (this->end - this->tail);
char *p = (char *) malloc (len);
if (p)
{
memcpy (p, this->start, this->head - this->start);
memcpy (p + (this->head - this->start), this->tail, this->end - this->tail);
}
else
return hb_bytes_t ();
if (unlikely (!p)) return hb_bytes_t ();
memcpy (p, this->start, this->head - this->start);
memcpy (p + (this->head - this->start), this->tail, this->end - this->tail);
return hb_bytes_t (p, len);
}
template <typename Type>