Reduce captures of lambdas

This commit is contained in:
Behdad Esfahbod 2019-05-15 18:15:05 -07:00
parent 5266ca86b6
commit 78d35f0e78
9 changed files with 31 additions and 30 deletions

View File

@ -108,7 +108,7 @@ struct hdmx
this->sizeDeviceRecord = DeviceRecord::get_size (it ? (*it).second.len () : 0);
+ it
| hb_apply ([&] (const hb_item_type<Iterator>& _) {
| hb_apply ([c] (const hb_item_type<Iterator>& _) {
c->start_embed<DeviceRecord> ()->serialize (c, _.first, _.second);
})
;
@ -126,7 +126,7 @@ struct hdmx
auto it =
+ hb_range ((unsigned) numRecords)
| hb_map ([&] (unsigned _)
| hb_map ([c, this] (unsigned _)
{
const DeviceRecord *device_record =
&StructAtOffset<DeviceRecord> (&firstDeviceRecord,

View File

@ -726,7 +726,7 @@ struct PairPosFormat1
+ hb_zip (this+coverage, pairSet)
| hb_filter (*glyphs, hb_first)
| hb_map (hb_second)
| hb_map ([&] (const OffsetTo<PairSet> &_) -> bool
| hb_map ([=] (const OffsetTo<PairSet> &_)
{ return (this+_).intersects (glyphs, valueFormat); })
| hb_any
;

View File

@ -46,9 +46,10 @@ struct SingleSubstFormat1
void closure (hb_closure_context_t *c) const
{
unsigned d = deltaGlyphID;
+ hb_iter (this+coverage)
| hb_filter (*c->glyphs)
| hb_map ([&] (hb_codepoint_t g) { return (g + deltaGlyphID) & 0xFFFFu; })
| hb_map ([d] (hb_codepoint_t g) { return (g + d) & 0xFFFFu; })
| hb_sink (c->output)
;
}
@ -56,9 +57,9 @@ struct SingleSubstFormat1
void collect_glyphs (hb_collect_glyphs_context_t *c) const
{
if (unlikely (!(this+coverage).add_coverage (c->input))) return;
unsigned d = deltaGlyphID;
+ hb_iter (this+coverage)
| hb_map ([&] (hb_codepoint_t g) { return (g + deltaGlyphID) & 0xFFFFu; })
| hb_map ([d] (hb_codepoint_t g) { return (g + d) & 0xFFFFu; })
| hb_sink (c->output)
;
}
@ -351,7 +352,7 @@ struct MultipleSubstFormat1
+ hb_zip (this+coverage, sequence)
| hb_filter (*c->glyphs, hb_first)
| hb_map (hb_second)
| hb_apply ([&] (const OffsetTo<Sequence> &_) { (this+_).closure (c); })
| hb_apply ([c, this] (const OffsetTo<Sequence> &_) { (this+_).closure (c); })
;
}
@ -360,7 +361,7 @@ struct MultipleSubstFormat1
if (unlikely (!(this+coverage).add_coverage (c->input))) return;
+ hb_zip (this+coverage, sequence)
| hb_map (hb_second)
| hb_apply ([&] (const OffsetTo<Sequence> &_) { (this+_).collect_glyphs (c); })
| hb_apply ([c, this] (const OffsetTo<Sequence> &_) { (this+_).collect_glyphs (c); })
;
}
@ -525,7 +526,7 @@ struct AlternateSubstFormat1
{
+ hb_zip (this+coverage, alternateSet)
| hb_map (hb_second)
| hb_apply ([&] (const OffsetTo<AlternateSet> &_) { (this+_).closure (c); })
| hb_apply ([c, this] (const OffsetTo<AlternateSet> &_) { (this+_).closure (c); })
;
}
@ -534,7 +535,7 @@ struct AlternateSubstFormat1
if (unlikely (!(this+coverage).add_coverage (c->input))) return;
+ hb_zip (this+coverage, alternateSet)
| hb_map (hb_second)
| hb_apply ([&] (const OffsetTo<AlternateSet> &_) { (this+_).collect_glyphs (c); })
| hb_apply ([c, this] (const OffsetTo<AlternateSet> &_) { (this+_).collect_glyphs (c); })
;
}
@ -741,7 +742,7 @@ struct LigatureSet
{
return
+ hb_iter (ligature)
| hb_map ([&] (const OffsetTo<Ligature> &_) { return (this+_).intersects (glyphs); })
| hb_map ([this, glyphs] (const OffsetTo<Ligature> &_) { return (this+_).intersects (glyphs); })
| hb_any
;
}
@ -749,14 +750,14 @@ struct LigatureSet
void closure (hb_closure_context_t *c) const
{
+ hb_iter (ligature)
| hb_apply ([&] (const OffsetTo<Ligature> &_) { (this+_).closure (c); })
| hb_apply ([this, c] (const OffsetTo<Ligature> &_) { (this+_).closure (c); })
;
}
void collect_glyphs (hb_collect_glyphs_context_t *c) const
{
+ hb_iter (ligature)
| hb_apply ([&] (const OffsetTo<Ligature> &_) { (this+_).collect_glyphs (c); })
| hb_apply ([this, c] (const OffsetTo<Ligature> &_) { (this+_).collect_glyphs (c); })
;
}
@ -764,7 +765,7 @@ struct LigatureSet
{
return
+ hb_iter (ligature)
| hb_map ([&] (const OffsetTo<Ligature> &_) { return (this+_).would_apply (c); })
| hb_map ([this, c] (const OffsetTo<Ligature> &_) { return (this+_).would_apply (c); })
| hb_any
;
}
@ -825,7 +826,7 @@ struct LigatureSubstFormat1
+ hb_zip (this+coverage, ligatureSet)
| hb_filter (*glyphs, hb_first)
| hb_map (hb_second)
| hb_map ([&] (const OffsetTo<LigatureSet> &_) -> bool
| hb_map ([this, glyphs] (const OffsetTo<LigatureSet> &_)
{ return (this+_).intersects (glyphs); })
| hb_any
;
@ -836,7 +837,7 @@ struct LigatureSubstFormat1
+ hb_zip (this+coverage, ligatureSet)
| hb_filter (*c->glyphs, hb_first)
| hb_map (hb_second)
| hb_apply ([&] (const OffsetTo<LigatureSet> &_) { (this+_).closure (c); })
| hb_apply ([this, c] (const OffsetTo<LigatureSet> &_) { (this+_).closure (c); })
;
}
@ -846,7 +847,7 @@ struct LigatureSubstFormat1
+ hb_zip (this+coverage, ligatureSet)
| hb_map (hb_second)
| hb_apply ([&] (const OffsetTo<LigatureSet> &_) { (this+_).collect_glyphs (c); })
| hb_apply ([this, c] (const OffsetTo<LigatureSet> &_) { (this+_).collect_glyphs (c); })
;
}

View File

@ -1546,7 +1546,7 @@ struct ContextFormat2
return
+ hb_enumerate (ruleSet)
| hb_map ([&] (const hb_pair_t<unsigned, const OffsetTo<RuleSet> &> p) -> bool
| hb_map ([&] (const hb_pair_t<unsigned, const OffsetTo<RuleSet> &> p)
{ return class_def.intersects_class (glyphs, p.first) &&
(this+p.second).intersects (glyphs, lookup_context); })
| hb_any
@ -1567,7 +1567,7 @@ struct ContextFormat2
return
+ hb_enumerate (ruleSet)
| hb_filter ([&] (unsigned _) -> bool
| hb_filter ([&] (unsigned _)
{ return class_def.intersects_class (c->glyphs, _); },
hb_first)
| hb_map (hb_second)
@ -2193,9 +2193,9 @@ struct ChainContextFormat2
return
+ hb_enumerate (ruleSet)
| hb_map ([&] (const hb_pair_t<unsigned, const OffsetTo<ChainRuleSet> &> p) -> bool
{ return input_class_def.intersects_class (glyphs, p.first) &&
(this+p.second).intersects (glyphs, lookup_context); })
| hb_map ([&] (const hb_pair_t<unsigned, const OffsetTo<ChainRuleSet> &> p)
{ return input_class_def.intersects_class (glyphs, p.first) &&
(this+p.second).intersects (glyphs, lookup_context); })
| hb_any
;
}
@ -2217,7 +2217,7 @@ struct ChainContextFormat2
return
+ hb_enumerate (ruleSet)
| hb_filter ([&] (unsigned _) -> bool
| hb_filter ([&] (unsigned _)
{ return input_class_def.intersects_class (c->glyphs, _); },
hb_first)
| hb_map (hb_second)

View File

@ -192,7 +192,7 @@ struct name
const void *dst_string_pool = &(this + this->stringOffset);
+ it
| hb_apply ([&] (const NameRecord& _) { c->copy (_, src_string_pool, dst_string_pool); })
| hb_apply ([=] (const NameRecord& _) { c->copy (_, src_string_pool, dst_string_pool); })
;
if (unlikely (c->ran_out_of_room)) return_trace (false);

View File

@ -289,7 +289,7 @@ struct STAT
;
+ get_axis_value_offsets ()
| hb_map ([&] (const OffsetTo<AxisValue>& _) { return hb_addressof (this + _); })
| hb_map ([this] (const OffsetTo<AxisValue>& _) { return hb_addressof (this + _); })
| hb_map (&AxisValue::get_value_name_id)
| hb_sink (nameids_to_retain)
;

View File

@ -290,12 +290,12 @@ struct fvar
;
+ hb_range ((unsigned) instanceCount)
| hb_map ([&] (const unsigned _) { return get_instance_subfamily_name_id (_); })
| hb_map ([this] (const unsigned _) { return get_instance_subfamily_name_id (_); })
| hb_sink (nameids)
;
+ hb_range ((unsigned) instanceCount)
| hb_map ([&] (const unsigned _) { return get_instance_postscript_name_id (_); })
| hb_map ([this] (const unsigned _) { return get_instance_postscript_name_id (_); })
| hb_sink (nameids)
;
}

View File

@ -177,7 +177,7 @@ _create_old_gid_to_new_gid_map (const hb_face_t *face,
*num_glyphs = reverse_glyph_map->get_population ();
} else {
+ hb_iter (all_gids_to_retain)
| hb_map ([=] (hb_codepoint_t _) {
| hb_map ([] (hb_codepoint_t _) {
return hb_pair_t<hb_codepoint_t, hb_codepoint_t> (_, _);
})
| hb_sink (reverse_glyph_map)

View File

@ -203,8 +203,8 @@ main (int argc, char **argv)
;
+ hb_iter (src)
| hb_map ([&] (int i) { return 1; })
| hb_reduce ([&] (int acc, int value) { return acc; }, 2)
| hb_map ([] (int i) { return 1; })
| hb_reduce ([=] (int acc, int value) { return acc; }, 2)
;
using map_pair_t = hb_item_type<hb_map_t>;