From 6d94194497b49ee4cd05c9f590f6cd871a5708e9 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Fri, 19 Feb 2021 17:08:10 -0700 Subject: [PATCH] Use auto in range-for-loop more --- src/hb-ot-cff-common.hh | 2 +- src/hb-ot-cmap-table.hh | 8 ++++---- src/hb-ot-layout-gsubgpos.hh | 6 ++++-- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/hb-ot-cff-common.hh b/src/hb-ot-cff-common.hh index e5286cd79..864a27f45 100644 --- a/src/hb-ot-cff-common.hh +++ b/src/hb-ot-cff-common.hh @@ -183,7 +183,7 @@ struct CFFIndex else { serialize_header(c, + it | hb_map ([] (const byte_str_t &_) { return _.length; })); - for (const byte_str_t &_ : +it) + for (const auto &_ : +it) _.copy (c); } return_trace (true); diff --git a/src/hb-ot-cmap-table.hh b/src/hb-ot-cmap-table.hh index cc48379bb..878e02ff1 100644 --- a/src/hb-ot-cmap-table.hh +++ b/src/hb-ot-cmap-table.hh @@ -95,7 +95,7 @@ struct CmapSubtableFormat4 HBUINT16 *endCode = c->start_embed (); hb_codepoint_t prev_endcp = 0xFFFF; - for (const hb_item_type _ : +it) + for (const auto& _ : +it) { if (prev_endcp != 0xFFFF && prev_endcp + 1u != _.first) { @@ -131,7 +131,7 @@ struct CmapSubtableFormat4 HBUINT16 *startCode = c->start_embed (); hb_codepoint_t prev_cp = 0xFFFF; - for (const hb_item_type _ : +it) + for (const auto& _ : +it) { if (prev_cp == 0xFFFF || prev_cp + 1u != _.first) { @@ -170,7 +170,7 @@ struct CmapSubtableFormat4 if ((char *)idDelta - (char *)startCode != (int) segcount * (int) HBINT16::static_size) return nullptr; - for (const hb_item_type _ : +it) + for (const auto& _ : +it) { if (_.first == startCode[i]) { @@ -696,7 +696,7 @@ struct CmapSubtableFormat12 : CmapSubtableLongSegmented hb_codepoint_t startCharCode = 0xFFFF, endCharCode = 0xFFFF; hb_codepoint_t glyphID = 0; - for (const hb_item_type _ : +it) + for (const auto& _ : +it) { if (startCharCode == 0xFFFF) { diff --git a/src/hb-ot-layout-gsubgpos.hh b/src/hb-ot-layout-gsubgpos.hh index c8fe9441a..aa46befbe 100644 --- a/src/hb-ot-layout-gsubgpos.hh +++ b/src/hb-ot-layout-gsubgpos.hh @@ -1882,8 +1882,8 @@ struct ContextFormat2 const hb_map_t *lookup_map = c->table_tag == HB_OT_TAG_GSUB ? c->plan->gsub_lookups : c->plan->gpos_lookups; bool ret = true; int non_zero_index = 0, index = 0; - for (const hb_pair_t&> _ : + hb_enumerate (ruleSet) - | hb_filter (klass_map, hb_first)) + for (const auto& _ : + hb_enumerate (ruleSet) + | hb_filter (klass_map, hb_first)) { auto *o = out->ruleSet.serialize_append (c->serializer); if (unlikely (!o)) @@ -2034,6 +2034,7 @@ struct ContextFormat3 for (const OffsetTo& offset : coverages) { + /* TODO(subset) This looks like should not be necessary to write this way. */ auto *o = c->serializer->allocate_size> (OffsetTo::static_size); if (unlikely (!o)) return_trace (false); if (!o->serialize_subset (c, offset, this)) return_trace (false); @@ -2323,6 +2324,7 @@ struct ChainRule c->copy (len); for (const auto g : it) { + /* TODO(constexpr) Simplify. */ HBUINT16 gid; gid = g; c->copy (gid);