From 015af5a8e5bbcfbc63328a1196318621ed21e1e7 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Thu, 1 Dec 2022 20:08:59 -0700 Subject: [PATCH] [subset-cff] Write a couple loops as range-based for --- src/hb-subset-cff-common.hh | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/src/hb-subset-cff-common.hh b/src/hb-subset-cff-common.hh index 2ca9ab144..0f8bc15cc 100644 --- a/src/hb-subset-cff-common.hh +++ b/src/hb-subset-cff-common.hh @@ -936,24 +936,21 @@ struct subr_subsetter_t if (!str.has_calls ()) return; - auto *values = str.values.arrayZ; - unsigned count = str.values.length; - for (unsigned i = 0; i < count; i++) + for (auto &opstr : str.values) { - auto &value = values[i]; - if (hinting || !value.is_hinting ()) + if (hinting || !opstr.is_hinting ()) { - switch (value.op) + switch (opstr.op) { case OpCode_callsubr: collect_subr_refs_in_subr (hinting, - value.subr_num, *param.parsed_local_subrs, + opstr.subr_num, *param.parsed_local_subrs, param.local_closure, param); break; case OpCode_callgsubr: collect_subr_refs_in_subr (hinting, - value.subr_num, *param.parsed_global_subrs, + opstr.subr_num, *param.parsed_global_subrs, param.global_closure, param); break; @@ -965,7 +962,6 @@ struct subr_subsetter_t bool encode_str (const parsed_cs_str_t &str, const unsigned int fd, str_buff_t &buff) const { - unsigned count = str.get_count (); str_encoder_t encoder (buff); encoder.reset (); bool hinting = !(plan->flags & HB_SUBSET_FLAGS_NO_HINTING); @@ -977,21 +973,19 @@ struct subr_subsetter_t if (str.prefix_op () != OpCode_Invalid) encoder.encode_op (str.prefix_op ()); } - auto *arr = str.values.arrayZ; unsigned size = 0; - for (unsigned int i = 0; i < count; i++) + for (auto &opstr : str.values) { - size += arr[i].length; - if (arr[i].op == OpCode_callsubr || arr[i].op == OpCode_callgsubr) + size += opstr.length; + if (opstr.op == OpCode_callsubr || opstr.op == OpCode_callgsubr) size += 3; } if (!buff.alloc (size)) return false; - for (unsigned int i = 0; i < count; i++) + for (auto &opstr : str.values) { - const parsed_cs_op_t &opstr = arr[i]; if (hinting || !opstr.is_hinting ()) { switch (opstr.op)