[OT] Improve serialize syntax

For some definition of improvement...
This commit is contained in:
Behdad Esfahbod 2012-09-01 21:30:17 -04:00
parent bc5be24014
commit abcc5ac1fd
2 changed files with 5 additions and 4 deletions

View File

@ -600,9 +600,11 @@ struct GenericOffsetTo : OffsetType
return StructAtOffset<Type> (base, offset); return StructAtOffset<Type> (base, offset);
} }
inline void set_offset (void *base, void *obj) inline Type& serialize (hb_serialize_context_t *c, void *base)
{ {
this->set ((char *) obj - (char *) base); Type *t = (Type *) c->head;
this->set ((char *) t - (char *) base);
return *t;
} }
inline bool sanitize (hb_sanitize_context_t *c, void *base) { inline bool sanitize (hb_sanitize_context_t *c, void *base) {

View File

@ -79,9 +79,8 @@ struct SingleSubstFormat1
{ {
TRACE_SERIALIZE (); TRACE_SERIALIZE ();
if (unlikely (!c->extend_min (*this))) return TRACE_RETURN (false); if (unlikely (!c->extend_min (*this))) return TRACE_RETURN (false);
if (unlikely (!coverage.serialize (c, this).serialize (c, glyphs, num_glyphs))) return TRACE_RETURN (false);
deltaGlyphID.set (delta); deltaGlyphID.set (delta);
coverage.set_offset (this, c->head);
if (unlikely (!(this+coverage).serialize (c, glyphs, num_glyphs))) return TRACE_RETURN (false);
return TRACE_RETURN (true); return TRACE_RETURN (true);
} }