From 6922a2561f75468c328fa158fef289a0b4156d87 Mon Sep 17 00:00:00 2001 From: Garret Rieger Date: Fri, 29 Apr 2022 23:30:32 +0000 Subject: [PATCH] [subset] Change serialize_rangeoffset_glyid back to using iterator. --- src/hb-ot-cmap-table.hh | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/hb-ot-cmap-table.hh b/src/hb-ot-cmap-table.hh index 74434c4f5..b36f40b6b 100644 --- a/src/hb-ot-cmap-table.hh +++ b/src/hb-ot-cmap-table.hh @@ -285,14 +285,16 @@ struct CmapSubtableFormat4 return true; } + template HBUINT16* serialize_rangeoffset_glyid (hb_serialize_context_t *c, - const hb_vector_t>& cp_to_gid_vector, + Iterator it, HBUINT16 *endCode, HBUINT16 *startCode, HBINT16 *idDelta, unsigned segcount) { - hb_hashmap_t cp_to_gid {cp_to_gid_vector.iter()}; + hb_hashmap_t cp_to_gid { it }; HBUINT16 *idRangeOffset = c->allocate_size (HBUINT16::static_size * segcount); if (unlikely (!c->check_success (idRangeOffset))) return nullptr; @@ -330,8 +332,10 @@ struct CmapSubtableFormat4 if (unlikely (!c->extend_min (this))) return; this->format = 4; - hb_vector_t> cp_to_gid; - + format4_iter | hb_sink (cp_to_gid); + // TODO(grieger): does pre-alloc make this faster? + hb_vector_t> cp_to_gid { + format4_iter + }; //serialize endCode[], startCode[], idDelta[] HBUINT16* endCode = c->start_embed (); @@ -343,7 +347,7 @@ struct CmapSubtableFormat4 HBINT16 *idDelta = ((HBINT16*)startCode) + segcount; HBUINT16 *idRangeOffset = serialize_rangeoffset_glyid (c, - cp_to_gid, + cp_to_gid.iter (), endCode, startCode, idDelta,