[serialize] Extract iterable copy, copy_all

This commit is contained in:
Ebrahim Byagowi 2019-09-23 23:48:08 +03:30 committed by Behdad Esfahbod
parent 35218c488c
commit 486754a888
5 changed files with 13 additions and 10 deletions

View File

@ -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);

View File

@ -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

View File

@ -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);

View File

@ -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

View File

@ -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; }