From abcc5ac1fde1c493e4055dd2f27b8aade7713156 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Sat, 1 Sep 2012 21:30:17 -0400 Subject: [PATCH] [OT] Improve serialize syntax For some definition of improvement... --- src/hb-open-type-private.hh | 6 ++++-- src/hb-ot-layout-gsub-table.hh | 3 +-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/hb-open-type-private.hh b/src/hb-open-type-private.hh index 70a7d9d19..6e9ed16d3 100644 --- a/src/hb-open-type-private.hh +++ b/src/hb-open-type-private.hh @@ -600,9 +600,11 @@ struct GenericOffsetTo : OffsetType return StructAtOffset (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) { diff --git a/src/hb-ot-layout-gsub-table.hh b/src/hb-ot-layout-gsub-table.hh index 714b44476..ea28bcc2c 100644 --- a/src/hb-ot-layout-gsub-table.hh +++ b/src/hb-ot-layout-gsub-table.hh @@ -79,9 +79,8 @@ struct SingleSubstFormat1 { TRACE_SERIALIZE (); 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); - coverage.set_offset (this, c->head); - if (unlikely (!(this+coverage).serialize (c, glyphs, num_glyphs))) return TRACE_RETURN (false); return TRACE_RETURN (true); }