From 1d9801e01290a62cfb802971061b2cc9f7c43bc1 Mon Sep 17 00:00:00 2001 From: Garret Rieger Date: Mon, 5 Oct 2020 14:41:55 -0700 Subject: [PATCH] [subset] In AnchorMatrix::subset eliminate the use of dynamically allocated vector. --- src/hb-ot-layout-gpos-table.hh | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/src/hb-ot-layout-gpos-table.hh b/src/hb-ot-layout-gpos-table.hh index 8b69da270..b7eee4d9b 100644 --- a/src/hb-ot-layout-gpos-table.hh +++ b/src/hb-ot-layout-gpos-table.hh @@ -548,7 +548,6 @@ struct AnchorMatrix const hb_map_t *layout_variation_idx_map, Iterator index_iter) { - // TODO(grieger): can serialize with an iterator of anchor's? TRACE_SERIALIZE (this); if (!index_iter) return_trace (false); if (unlikely (!c->extend_min ((*this)))) return_trace (false); @@ -574,22 +573,16 @@ struct AnchorMatrix TRACE_SUBSET (this); auto *out = c->serializer->start_embed (*this); - // TODO(grieger): shouldn't need to use an allocated vector to do this. - hb_vector_t indexes; - for (unsigned row : + hb_range ((unsigned) rows)) - { - + hb_range (cols) - | hb_filter (klass_mapping) - | hb_map ([=] (const unsigned col) { return row * cols + col; }) - | hb_sink (indexes) - ; - } + auto indexes = + + hb_range (rows * cols) + | hb_filter ([=] (unsigned index) { return klass_mapping->has (index % cols); }) + ; out->serialize (c->serializer, (unsigned) rows, this, c->plan->layout_variation_idx_map, - indexes.iter ()); + indexes); return_trace (true); }