From 482c6e5dc41402e60acf609fca0d9d8e8fbc4d9d Mon Sep 17 00:00:00 2001 From: Garret Rieger Date: Wed, 18 May 2022 19:58:55 +0000 Subject: [PATCH] [subset-perf] Speed up Coverage::serialize by caching iterator. --- src/hb-ot-layout-common.hh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/hb-ot-layout-common.hh b/src/hb-ot-layout-common.hh index 7c4d827c8..b0f2faaf5 100644 --- a/src/hb-ot-layout-common.hh +++ b/src/hb-ot-layout-common.hh @@ -1725,9 +1725,12 @@ struct Coverage | hb_filter (glyphset) | hb_map_retains_sorting (glyph_map) ; + // Cache the iterator result as it will be iterated multiple times + // by the serialize code below. + hb_sorted_vector_t glyphs (it); - bool ret = bool (it); - Coverage_serialize (c->serializer, it); + bool ret = bool (glyphs); + Coverage_serialize (c->serializer, glyphs.iter ()); return_trace (ret); }