Turn more of simple dagger chains to foreach

Less noise, as was agreed before and applied 385741d also
This commit is contained in:
Ebrahim Byagowi 2020-03-13 08:33:34 +03:30 committed by GitHub
parent 755a77d660
commit a224f4179f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 74 additions and 90 deletions

View File

@ -184,7 +184,8 @@ struct CFFIndex
else
{
serialize_header(c, + it | hb_map ([] (const byte_str_t &_) { return _.length; }));
+ it | hb_apply ([&] (const byte_str_t &_) { _.copy (c); });
for (const byte_str_t &_ : +it)
_.copy (c);
}
return_trace (true);
}
@ -221,15 +222,13 @@ struct CFFIndex
return_trace (false);
/* serialize indices */
unsigned int offset = 1;
unsigned int i = 0;
+ it
| hb_apply ([&] (unsigned _)
{
CFFIndex<COUNT>::set_offset_at (i++, offset);
offset += _;
})
;
unsigned int offset = 1;
unsigned int i = 0;
for (unsigned _ : +it)
{
CFFIndex<COUNT>::set_offset_at (i++, offset);
offset += _;
}
CFFIndex<COUNT>::set_offset_at (i, offset);
return_trace (true);
@ -418,7 +417,7 @@ struct Dict : UnsizedByteStr
c->add_link (ofs, link, whence);
return true;
}
static bool serialize_link4_op (hb_serialize_context_t *c, op_code_t op, objidx_t link, whence_t whence = whence_t::Head)
{ return serialize_link_op<HBINT32, OpCode_longintdict> (c, op, link, whence); }

View File

@ -83,18 +83,16 @@ struct CmapSubtableFormat4
HBUINT16 *endCode = c->start_embed<HBUINT16> ();
hb_codepoint_t prev_endcp = 0xFFFF;
+ it
| hb_apply ([&] (const hb_item_type<Iterator> _)
{
if (prev_endcp != 0xFFFF && prev_endcp + 1u != _.first)
{
HBUINT16 end_code;
end_code = prev_endcp;
c->copy<HBUINT16> (end_code);
}
prev_endcp = _.first;
})
;
for (const hb_item_type<Iterator> _ : +it)
{
if (prev_endcp != 0xFFFF && prev_endcp + 1u != _.first)
{
HBUINT16 end_code;
end_code = prev_endcp;
c->copy<HBUINT16> (end_code);
}
prev_endcp = _.first;
}
{
// last endCode
@ -121,19 +119,17 @@ struct CmapSubtableFormat4
HBUINT16 *startCode = c->start_embed<HBUINT16> ();
hb_codepoint_t prev_cp = 0xFFFF;
+ it
| hb_apply ([&] (const hb_item_type<Iterator> _)
{
if (prev_cp == 0xFFFF || prev_cp + 1u != _.first)
{
HBUINT16 start_code;
start_code = _.first;
c->copy<HBUINT16> (start_code);
}
for (const hb_item_type<Iterator> _ : +it)
{
if (prev_cp == 0xFFFF || prev_cp + 1u != _.first)
{
HBUINT16 start_code;
start_code = _.first;
c->copy<HBUINT16> (start_code);
}
prev_cp = _.first;
})
;
prev_cp = _.first;
}
// There must be a final entry with end_code == 0xFFFF.
if (it.len () == 0 || prev_cp != 0xFFFF)
@ -162,30 +158,28 @@ struct CmapSubtableFormat4
if ((char *)idDelta - (char *)startCode != (int) segcount * (int) HBINT16::static_size)
return nullptr;
+ it
| hb_apply ([&] (const hb_item_type<Iterator> _)
{
if (_.first == startCode[i])
{
use_delta = true;
start_gid = _.second;
}
else if (_.second != last_gid + 1) use_delta = false;
for (const hb_item_type<Iterator> _ : +it)
{
if (_.first == startCode[i])
{
use_delta = true;
start_gid = _.second;
}
else if (_.second != last_gid + 1) use_delta = false;
if (_.first == endCode[i])
{
HBINT16 delta;
if (use_delta) delta = (int)start_gid - (int)startCode[i];
else delta = 0;
c->copy<HBINT16> (delta);
if (_.first == endCode[i])
{
HBINT16 delta;
if (use_delta) delta = (int)start_gid - (int)startCode[i];
else delta = 0;
c->copy<HBINT16> (delta);
i++;
}
i++;
}
last_gid = _.second;
last_cp = _.first;
})
;
last_gid = _.second;
last_cp = _.first;
}
if (it.len () == 0 || last_cp != 0xFFFF)
{
@ -599,33 +593,29 @@ struct CmapSubtableFormat12 : CmapSubtableLongSegmented<CmapSubtableFormat12>
hb_codepoint_t startCharCode = 0xFFFF, endCharCode = 0xFFFF;
hb_codepoint_t glyphID = 0;
+ it
| hb_apply ([&] (const hb_item_type<Iterator> _)
{
if (startCharCode == 0xFFFF)
{
startCharCode = _.first;
endCharCode = _.first;
glyphID = _.second;
}
else if (!_is_gid_consecutive (endCharCode, startCharCode, glyphID, _.first, _.second))
{
CmapSubtableLongGroup grouprecord;
grouprecord.startCharCode = startCharCode;
grouprecord.endCharCode = endCharCode;
grouprecord.glyphID = glyphID;
c->copy<CmapSubtableLongGroup> (grouprecord);
for (const hb_item_type<Iterator> _ : +it)
{
if (startCharCode == 0xFFFF)
{
startCharCode = _.first;
endCharCode = _.first;
glyphID = _.second;
}
else if (!_is_gid_consecutive (endCharCode, startCharCode, glyphID, _.first, _.second))
{
CmapSubtableLongGroup grouprecord;
grouprecord.startCharCode = startCharCode;
grouprecord.endCharCode = endCharCode;
grouprecord.glyphID = glyphID;
c->copy<CmapSubtableLongGroup> (grouprecord);
startCharCode = _.first;
endCharCode = _.first;
glyphID = _.second;
}
else
{
endCharCode = _.first;
}
})
;
startCharCode = _.first;
endCharCode = _.first;
glyphID = _.second;
}
else
endCharCode = _.first;
}
CmapSubtableLongGroup record;
record.startCharCode = startCharCode;

View File

@ -107,11 +107,8 @@ struct hdmx
this->numRecords = it.len ();
this->sizeDeviceRecord = DeviceRecord::get_size (it ? (*it).second.len () : 0);
+ it
| hb_apply ([c] (const hb_item_type<Iterator>& _) {
c->start_embed<DeviceRecord> ()->serialize (c, _.first, _.second);
})
;
for (const hb_item_type<Iterator>& _ : +it)
c->start_embed<DeviceRecord> ()->serialize (c, _.first, _.second);
return_trace (c->successful);
}

View File

@ -41,9 +41,7 @@ struct hb_pool_t
{
next = nullptr;
+ hb_iter (chunks)
| hb_apply ([] (chunk_t *_) { ::free (_); })
;
for (chunk_t *_ : chunks) ::free (_);
chunks.fini ();
}