From a4e0fd1685a8ea0a6ae7ddf034edbe1a622c57c1 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Fri, 5 Aug 2022 15:05:51 -0600 Subject: [PATCH] [MultipleSubst] Rewrite serialize signature as single iterator --- src/OT/Layout/GSUB/MultipleSubst.hh | 10 ++++------ src/OT/Layout/GSUB/MultipleSubstFormat1.hh | 19 +++++++++++++------ src/OT/Layout/GSUB/SubstLookup.hh | 12 ++++-------- 3 files changed, 21 insertions(+), 20 deletions(-) diff --git a/src/OT/Layout/GSUB/MultipleSubst.hh b/src/OT/Layout/GSUB/MultipleSubst.hh index 15d726177..852ca3eac 100644 --- a/src/OT/Layout/GSUB/MultipleSubst.hh +++ b/src/OT/Layout/GSUB/MultipleSubst.hh @@ -35,19 +35,17 @@ struct MultipleSubst } } - template + template bool serialize (hb_serialize_context_t *c, - GlyphIterator glyphs, - SequenceIterator sequences) + Iterator it) { TRACE_SERIALIZE (this); if (unlikely (!c->extend_min (u.format))) return_trace (false); unsigned int format = 1; u.format = format; switch (u.format) { - case 1: return_trace (u.format1.serialize (c, glyphs, sequences)); + case 1: return_trace (u.format1.serialize (c, it)); default:return_trace (false); } } diff --git a/src/OT/Layout/GSUB/MultipleSubstFormat1.hh b/src/OT/Layout/GSUB/MultipleSubstFormat1.hh index dbcc6f6df..3b4bd1169 100644 --- a/src/OT/Layout/GSUB/MultipleSubstFormat1.hh +++ b/src/OT/Layout/GSUB/MultipleSubstFormat1.hh @@ -71,16 +71,23 @@ struct MultipleSubstFormat1_2 return_trace ((this+sequence[index]).apply (c)); } - template + template bool serialize (hb_serialize_context_t *c, - GlyphIterator glyphs, - SequenceIterator sequences) + Iterator it) { TRACE_SERIALIZE (this); + auto sequences = + + it + | hb_map (hb_second) + ; + auto glyphs = + + it + | hb_map_retains_sorting (hb_first) + ; if (unlikely (!c->extend_min (this))) return_trace (false); - if (unlikely (!sequence.serialize (c, glyphs.length))) return_trace (false); + + if (unlikely (!sequence.serialize (c, sequences.length))) return_trace (false); for (auto& pair : hb_zip (sequences, sequence)) { diff --git a/src/OT/Layout/GSUB/SubstLookup.hh b/src/OT/Layout/GSUB/SubstLookup.hh index 28db0e428..d49dcc0e0 100644 --- a/src/OT/Layout/GSUB/SubstLookup.hh +++ b/src/OT/Layout/GSUB/SubstLookup.hh @@ -119,20 +119,16 @@ struct SubstLookup : Lookup return_trace (false); } - template + template bool serialize (hb_serialize_context_t *c, uint32_t lookup_props, - GlyphIterator glyphs, - SequenceIterator sequences) + Iterator it) { TRACE_SERIALIZE (this); if (unlikely (!Lookup::serialize (c, SubTable::Multiple, lookup_props, 1))) return_trace (false); if (c->push ()->u.multiple. - serialize (c, - glyphs, - sequences)) + serialize (c, it)) { c->add_link (get_subtables ()[0], c->pop_pack ()); return_trace (true);