[serialize] Extract iterable copy, copy_all
This commit is contained in:
parent
35218c488c
commit
486754a888
|
@ -941,9 +941,9 @@ struct CmapSubtableFormat14
|
|||
if (unlikely (!c->extend_min (*this))) return;
|
||||
this->format = 14;
|
||||
|
||||
const CmapSubtableFormat14 *src_tbl = reinterpret_cast<const CmapSubtableFormat14*> (src_base);
|
||||
for (const VariationSelectorRecord& _ : src_tbl->record)
|
||||
c->copy (_, unicodes, glyphs, glyph_map, src_base, this);
|
||||
auto src_tbl = reinterpret_cast<const CmapSubtableFormat14*> (src_base);
|
||||
c->copy_all (hb_iter (src_tbl->record),
|
||||
unicodes, glyphs, glyph_map, src_base, this);
|
||||
|
||||
if (c->length () - table_initpos == CmapSubtableFormat14::min_size)
|
||||
c->revert (snap);
|
||||
|
|
|
@ -544,8 +544,7 @@ struct SinglePosFormat1
|
|||
if (unlikely (!c->extend_min (*this))) return;
|
||||
if (unlikely (!c->check_assign (valueFormat, valFormat))) return;
|
||||
|
||||
for (const auto &_ : hb_second (*it))
|
||||
c->copy (_);
|
||||
c->copy_all (hb_second (*it));
|
||||
|
||||
auto glyphs =
|
||||
+ it
|
||||
|
@ -632,9 +631,7 @@ struct SinglePosFormat2
|
|||
if (unlikely (!c->check_assign (valueFormat, valFormat))) return;
|
||||
if (unlikely (!c->check_assign (valueCount, it.len ()))) return;
|
||||
|
||||
for (const auto iter : it)
|
||||
for (const auto &_ : iter.second)
|
||||
c->copy (_);
|
||||
for (auto iter : it) c->copy_all (iter.second);
|
||||
|
||||
auto glyphs =
|
||||
+ it
|
||||
|
|
|
@ -191,7 +191,7 @@ struct name
|
|||
|
||||
const void *dst_string_pool = &(this + this->stringOffset);
|
||||
|
||||
for (const auto &_ : it) c->copy (_, src_string_pool, dst_string_pool);
|
||||
c->copy_all (it, src_string_pool, dst_string_pool);
|
||||
|
||||
if (unlikely (c->ran_out_of_room)) return_trace (false);
|
||||
|
||||
|
|
|
@ -84,7 +84,7 @@ struct VORG
|
|||
this->defaultVertOriginY = defaultVertOriginY;
|
||||
this->vertYOrigins.len = it.len ();
|
||||
|
||||
for (const auto _ : it) c->copy (_);
|
||||
c->copy_all (it);
|
||||
}
|
||||
|
||||
bool subset (hb_subset_context_t *c) const
|
||||
|
|
|
@ -387,6 +387,12 @@ struct hb_serialize_context_t
|
|||
Type *copy (const Type *src, Ts&&... ds)
|
||||
{ return copy (*src, hb_forward<Ts> (ds)...); }
|
||||
|
||||
template<typename Iterator,
|
||||
hb_requires (hb_is_iterator (Iterator)),
|
||||
typename ...Ts>
|
||||
void copy_all (Iterator it, Ts&&... ds)
|
||||
{ for (decltype (*it) _ : it) copy (_, hb_forward<Ts> (ds)...); }
|
||||
|
||||
template <typename Type>
|
||||
hb_serialize_context_t& operator << (const Type &obj) & { embed (obj); return *this; }
|
||||
|
||||
|
|
Loading…
Reference in New Issue