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 else
{ {
serialize_header(c, + it | hb_map ([] (const byte_str_t &_) { return _.length; })); 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); return_trace (true);
} }
@ -221,15 +222,13 @@ struct CFFIndex
return_trace (false); return_trace (false);
/* serialize indices */ /* serialize indices */
unsigned int offset = 1; unsigned int offset = 1;
unsigned int i = 0; unsigned int i = 0;
+ it for (unsigned _ : +it)
| hb_apply ([&] (unsigned _) {
{ CFFIndex<COUNT>::set_offset_at (i++, offset);
CFFIndex<COUNT>::set_offset_at (i++, offset); offset += _;
offset += _; }
})
;
CFFIndex<COUNT>::set_offset_at (i, offset); CFFIndex<COUNT>::set_offset_at (i, offset);
return_trace (true); return_trace (true);
@ -418,7 +417,7 @@ struct Dict : UnsizedByteStr
c->add_link (ofs, link, whence); c->add_link (ofs, link, whence);
return true; 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) 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); } { 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> (); HBUINT16 *endCode = c->start_embed<HBUINT16> ();
hb_codepoint_t prev_endcp = 0xFFFF; hb_codepoint_t prev_endcp = 0xFFFF;
+ it for (const hb_item_type<Iterator> _ : +it)
| hb_apply ([&] (const hb_item_type<Iterator> _) {
{ if (prev_endcp != 0xFFFF && prev_endcp + 1u != _.first)
if (prev_endcp != 0xFFFF && prev_endcp + 1u != _.first) {
{ HBUINT16 end_code;
HBUINT16 end_code; end_code = prev_endcp;
end_code = prev_endcp; c->copy<HBUINT16> (end_code);
c->copy<HBUINT16> (end_code); }
} prev_endcp = _.first;
prev_endcp = _.first; }
})
;
{ {
// last endCode // last endCode
@ -121,19 +119,17 @@ struct CmapSubtableFormat4
HBUINT16 *startCode = c->start_embed<HBUINT16> (); HBUINT16 *startCode = c->start_embed<HBUINT16> ();
hb_codepoint_t prev_cp = 0xFFFF; hb_codepoint_t prev_cp = 0xFFFF;
+ it for (const hb_item_type<Iterator> _ : +it)
| hb_apply ([&] (const hb_item_type<Iterator> _) {
{ if (prev_cp == 0xFFFF || prev_cp + 1u != _.first)
if (prev_cp == 0xFFFF || prev_cp + 1u != _.first) {
{ HBUINT16 start_code;
HBUINT16 start_code; start_code = _.first;
start_code = _.first; c->copy<HBUINT16> (start_code);
c->copy<HBUINT16> (start_code); }
}
prev_cp = _.first; prev_cp = _.first;
}) }
;
// There must be a final entry with end_code == 0xFFFF. // There must be a final entry with end_code == 0xFFFF.
if (it.len () == 0 || prev_cp != 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) if ((char *)idDelta - (char *)startCode != (int) segcount * (int) HBINT16::static_size)
return nullptr; return nullptr;
+ it for (const hb_item_type<Iterator> _ : +it)
| hb_apply ([&] (const hb_item_type<Iterator> _) {
{ if (_.first == startCode[i])
if (_.first == startCode[i]) {
{ use_delta = true;
use_delta = true; start_gid = _.second;
start_gid = _.second; }
} else if (_.second != last_gid + 1) use_delta = false;
else if (_.second != last_gid + 1) use_delta = false;
if (_.first == endCode[i]) if (_.first == endCode[i])
{ {
HBINT16 delta; HBINT16 delta;
if (use_delta) delta = (int)start_gid - (int)startCode[i]; if (use_delta) delta = (int)start_gid - (int)startCode[i];
else delta = 0; else delta = 0;
c->copy<HBINT16> (delta); c->copy<HBINT16> (delta);
i++; i++;
} }
last_gid = _.second; last_gid = _.second;
last_cp = _.first; last_cp = _.first;
}) }
;
if (it.len () == 0 || last_cp != 0xFFFF) 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 startCharCode = 0xFFFF, endCharCode = 0xFFFF;
hb_codepoint_t glyphID = 0; hb_codepoint_t glyphID = 0;
+ it for (const hb_item_type<Iterator> _ : +it)
| hb_apply ([&] (const hb_item_type<Iterator> _) {
{ if (startCharCode == 0xFFFF)
if (startCharCode == 0xFFFF) {
{ startCharCode = _.first;
startCharCode = _.first; endCharCode = _.first;
endCharCode = _.first; glyphID = _.second;
glyphID = _.second; }
} else if (!_is_gid_consecutive (endCharCode, startCharCode, glyphID, _.first, _.second))
else if (!_is_gid_consecutive (endCharCode, startCharCode, glyphID, _.first, _.second)) {
{ CmapSubtableLongGroup grouprecord;
CmapSubtableLongGroup grouprecord; grouprecord.startCharCode = startCharCode;
grouprecord.startCharCode = startCharCode; grouprecord.endCharCode = endCharCode;
grouprecord.endCharCode = endCharCode; grouprecord.glyphID = glyphID;
grouprecord.glyphID = glyphID; c->copy<CmapSubtableLongGroup> (grouprecord);
c->copy<CmapSubtableLongGroup> (grouprecord);
startCharCode = _.first; startCharCode = _.first;
endCharCode = _.first; endCharCode = _.first;
glyphID = _.second; glyphID = _.second;
} }
else else
{ endCharCode = _.first;
endCharCode = _.first; }
}
})
;
CmapSubtableLongGroup record; CmapSubtableLongGroup record;
record.startCharCode = startCharCode; record.startCharCode = startCharCode;

View File

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

View File

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