[subset-cff] Write a couple loops as range-based for
This commit is contained in:
parent
bfbbd4af25
commit
015af5a8e5
|
@ -936,24 +936,21 @@ struct subr_subsetter_t
|
||||||
if (!str.has_calls ())
|
if (!str.has_calls ())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
auto *values = str.values.arrayZ;
|
for (auto &opstr : str.values)
|
||||||
unsigned count = str.values.length;
|
|
||||||
for (unsigned i = 0; i < count; i++)
|
|
||||||
{
|
{
|
||||||
auto &value = values[i];
|
if (hinting || !opstr.is_hinting ())
|
||||||
if (hinting || !value.is_hinting ())
|
|
||||||
{
|
{
|
||||||
switch (value.op)
|
switch (opstr.op)
|
||||||
{
|
{
|
||||||
case OpCode_callsubr:
|
case OpCode_callsubr:
|
||||||
collect_subr_refs_in_subr (hinting,
|
collect_subr_refs_in_subr (hinting,
|
||||||
value.subr_num, *param.parsed_local_subrs,
|
opstr.subr_num, *param.parsed_local_subrs,
|
||||||
param.local_closure, param);
|
param.local_closure, param);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case OpCode_callgsubr:
|
case OpCode_callgsubr:
|
||||||
collect_subr_refs_in_subr (hinting,
|
collect_subr_refs_in_subr (hinting,
|
||||||
value.subr_num, *param.parsed_global_subrs,
|
opstr.subr_num, *param.parsed_global_subrs,
|
||||||
param.global_closure, param);
|
param.global_closure, param);
|
||||||
break;
|
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
|
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);
|
str_encoder_t encoder (buff);
|
||||||
encoder.reset ();
|
encoder.reset ();
|
||||||
bool hinting = !(plan->flags & HB_SUBSET_FLAGS_NO_HINTING);
|
bool hinting = !(plan->flags & HB_SUBSET_FLAGS_NO_HINTING);
|
||||||
|
@ -977,21 +973,19 @@ struct subr_subsetter_t
|
||||||
if (str.prefix_op () != OpCode_Invalid)
|
if (str.prefix_op () != OpCode_Invalid)
|
||||||
encoder.encode_op (str.prefix_op ());
|
encoder.encode_op (str.prefix_op ());
|
||||||
}
|
}
|
||||||
auto *arr = str.values.arrayZ;
|
|
||||||
|
|
||||||
unsigned size = 0;
|
unsigned size = 0;
|
||||||
for (unsigned int i = 0; i < count; i++)
|
for (auto &opstr : str.values)
|
||||||
{
|
{
|
||||||
size += arr[i].length;
|
size += opstr.length;
|
||||||
if (arr[i].op == OpCode_callsubr || arr[i].op == OpCode_callgsubr)
|
if (opstr.op == OpCode_callsubr || opstr.op == OpCode_callgsubr)
|
||||||
size += 3;
|
size += 3;
|
||||||
}
|
}
|
||||||
if (!buff.alloc (size))
|
if (!buff.alloc (size))
|
||||||
return false;
|
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 ())
|
if (hinting || !opstr.is_hinting ())
|
||||||
{
|
{
|
||||||
switch (opstr.op)
|
switch (opstr.op)
|
||||||
|
|
Loading…
Reference in New Issue