Use hb_enumerate instead of hand-coding
This commit is contained in:
parent
4d19c724c0
commit
02bc4dd69b
|
@ -980,18 +980,16 @@ struct RecordListOfFeature : RecordListOf<Feature>
|
||||||
auto *out = c->serializer->start_embed (*this);
|
auto *out = c->serializer->start_embed (*this);
|
||||||
if (unlikely (!out || !c->serializer->extend_min (out))) return_trace (false);
|
if (unlikely (!out || !c->serializer->extend_min (out))) return_trace (false);
|
||||||
|
|
||||||
unsigned count = this->len;
|
+ hb_enumerate (*this)
|
||||||
|
| hb_filter (l->feature_index_map, hb_first)
|
||||||
+ hb_zip (*this, hb_range (count))
|
| hb_apply ([l, out, this] (const hb_pair_t<unsigned, const Record<Feature>&>& _)
|
||||||
| hb_filter (l->feature_index_map, hb_second)
|
|
||||||
| hb_apply ([l, out, this] (const hb_pair_t<const Record<Feature>&, unsigned>& _)
|
|
||||||
{
|
{
|
||||||
const Feature *f_sub = nullptr;
|
const Feature *f_sub = nullptr;
|
||||||
const Feature **f = nullptr;
|
const Feature **f = nullptr;
|
||||||
if (l->feature_substitutes_map->has (_.second, &f))
|
if (l->feature_substitutes_map->has (_.first, &f))
|
||||||
f_sub = *f;
|
f_sub = *f;
|
||||||
|
|
||||||
subset_record_array (l, out, this, f_sub) (_.first);
|
subset_record_array (l, out, this, f_sub) (_.second);
|
||||||
})
|
})
|
||||||
;
|
;
|
||||||
|
|
||||||
|
@ -1147,7 +1145,6 @@ struct Script
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned langsys_count = get_lang_sys_count ();
|
|
||||||
if (has_default_lang_sys ())
|
if (has_default_lang_sys ())
|
||||||
{
|
{
|
||||||
//only collect features from non-redundant langsys
|
//only collect features from non-redundant langsys
|
||||||
|
@ -1156,24 +1153,24 @@ struct Script
|
||||||
d.collect_features (c);
|
d.collect_features (c);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto _ : + hb_zip (langSys, hb_range (langsys_count)))
|
for (auto _ : + hb_enumerate (langSys))
|
||||||
{
|
{
|
||||||
const LangSys& l = this+_.first.offset;
|
const LangSys& l = this+_.second.offset;
|
||||||
if (!c->visitLangsys (l.get_feature_count ())) continue;
|
if (!c->visitLangsys (l.get_feature_count ())) continue;
|
||||||
if (l.compare (d, c->duplicate_feature_map)) continue;
|
if (l.compare (d, c->duplicate_feature_map)) continue;
|
||||||
|
|
||||||
l.collect_features (c);
|
l.collect_features (c);
|
||||||
c->script_langsys_map->get (script_index)->add (_.second);
|
c->script_langsys_map->get (script_index)->add (_.first);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (auto _ : + hb_zip (langSys, hb_range (langsys_count)))
|
for (auto _ : + hb_enumerate (langSys))
|
||||||
{
|
{
|
||||||
const LangSys& l = this+_.first.offset;
|
const LangSys& l = this+_.second.offset;
|
||||||
if (!c->visitLangsys (l.get_feature_count ())) continue;
|
if (!c->visitLangsys (l.get_feature_count ())) continue;
|
||||||
l.collect_features (c);
|
l.collect_features (c);
|
||||||
c->script_langsys_map->get (script_index)->add (_.second);
|
c->script_langsys_map->get (script_index)->add (_.first);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1211,10 +1208,9 @@ struct Script
|
||||||
const hb_set_t *active_langsys = l->script_langsys_map->get (l->cur_script_index);
|
const hb_set_t *active_langsys = l->script_langsys_map->get (l->cur_script_index);
|
||||||
if (active_langsys)
|
if (active_langsys)
|
||||||
{
|
{
|
||||||
unsigned count = langSys.len;
|
+ hb_enumerate (langSys)
|
||||||
+ hb_zip (langSys, hb_range (count))
|
| hb_filter (active_langsys, hb_first)
|
||||||
| hb_filter (active_langsys, hb_second)
|
| hb_map (hb_second)
|
||||||
| hb_map (hb_first)
|
|
||||||
| hb_filter ([=] (const Record<LangSys>& record) {return l->visitLangSys (); })
|
| hb_filter ([=] (const Record<LangSys>& record) {return l->visitLangSys (); })
|
||||||
| hb_apply (subset_record_array (l, &(out->langSys), this))
|
| hb_apply (subset_record_array (l, &(out->langSys), this))
|
||||||
;
|
;
|
||||||
|
@ -1250,12 +1246,11 @@ struct RecordListOfScript : RecordListOf<Script>
|
||||||
auto *out = c->serializer->start_embed (*this);
|
auto *out = c->serializer->start_embed (*this);
|
||||||
if (unlikely (!out || !c->serializer->extend_min (out))) return_trace (false);
|
if (unlikely (!out || !c->serializer->extend_min (out))) return_trace (false);
|
||||||
|
|
||||||
unsigned count = this->len;
|
for (auto _ : + hb_enumerate (*this))
|
||||||
for (auto _ : + hb_zip (*this, hb_range (count)))
|
|
||||||
{
|
{
|
||||||
auto snap = c->serializer->snapshot ();
|
auto snap = c->serializer->snapshot ();
|
||||||
l->cur_script_index = _.second;
|
l->cur_script_index = _.first;
|
||||||
bool ret = _.first.subset (l, this);
|
bool ret = _.second.subset (l, this);
|
||||||
if (!ret) c->serializer->revert (snap);
|
if (!ret) c->serializer->revert (snap);
|
||||||
else out->len++;
|
else out->len++;
|
||||||
}
|
}
|
||||||
|
@ -1460,10 +1455,9 @@ struct LookupOffsetList : List16OfOffsetTo<TLookup, OffsetType>
|
||||||
auto *out = c->serializer->start_embed (this);
|
auto *out = c->serializer->start_embed (this);
|
||||||
if (unlikely (!out || !c->serializer->extend_min (out))) return_trace (false);
|
if (unlikely (!out || !c->serializer->extend_min (out))) return_trace (false);
|
||||||
|
|
||||||
unsigned count = this->len;
|
+ hb_enumerate (*this)
|
||||||
+ hb_zip (*this, hb_range (count))
|
| hb_filter (l->lookup_index_map, hb_first)
|
||||||
| hb_filter (l->lookup_index_map, hb_second)
|
| hb_map (hb_second)
|
||||||
| hb_map (hb_first)
|
|
||||||
| hb_apply (subset_offset_array (c, *out, this))
|
| hb_apply (subset_offset_array (c, *out, this))
|
||||||
;
|
;
|
||||||
return_trace (true);
|
return_trace (true);
|
||||||
|
|
Loading…
Reference in New Issue