From 78d35f0e780dd811ae103c96f3b1060d49046a7a Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Wed, 15 May 2019 18:15:05 -0700 Subject: [PATCH] Reduce captures of lambdas --- src/hb-ot-hdmx-table.hh | 4 ++-- src/hb-ot-layout-gpos-table.hh | 2 +- src/hb-ot-layout-gsub-table.hh | 29 +++++++++++++++-------------- src/hb-ot-layout-gsubgpos.hh | 12 ++++++------ src/hb-ot-name-table.hh | 2 +- src/hb-ot-stat-table.hh | 2 +- src/hb-ot-var-fvar-table.hh | 4 ++-- src/hb-subset-plan.cc | 2 +- src/test-iter.cc | 4 ++-- 9 files changed, 31 insertions(+), 30 deletions(-) diff --git a/src/hb-ot-hdmx-table.hh b/src/hb-ot-hdmx-table.hh index dc36d0ab5..96c1d1f63 100644 --- a/src/hb-ot-hdmx-table.hh +++ b/src/hb-ot-hdmx-table.hh @@ -108,7 +108,7 @@ struct hdmx this->sizeDeviceRecord = DeviceRecord::get_size (it ? (*it).second.len () : 0); + it - | hb_apply ([&] (const hb_item_type& _) { + | hb_apply ([c] (const hb_item_type& _) { c->start_embed ()->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 (&firstDeviceRecord, diff --git a/src/hb-ot-layout-gpos-table.hh b/src/hb-ot-layout-gpos-table.hh index 45de78138..86c45be29 100644 --- a/src/hb-ot-layout-gpos-table.hh +++ b/src/hb-ot-layout-gpos-table.hh @@ -726,7 +726,7 @@ struct PairPosFormat1 + hb_zip (this+coverage, pairSet) | hb_filter (*glyphs, hb_first) | hb_map (hb_second) - | hb_map ([&] (const OffsetTo &_) -> bool + | hb_map ([=] (const OffsetTo &_) { return (this+_).intersects (glyphs, valueFormat); }) | hb_any ; diff --git a/src/hb-ot-layout-gsub-table.hh b/src/hb-ot-layout-gsub-table.hh index 6937e8a72..fb18ce92a 100644 --- a/src/hb-ot-layout-gsub-table.hh +++ b/src/hb-ot-layout-gsub-table.hh @@ -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 &_) { (this+_).closure (c); }) + | hb_apply ([c, this] (const OffsetTo &_) { (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 &_) { (this+_).collect_glyphs (c); }) + | hb_apply ([c, this] (const OffsetTo &_) { (this+_).collect_glyphs (c); }) ; } @@ -525,7 +526,7 @@ struct AlternateSubstFormat1 { + hb_zip (this+coverage, alternateSet) | hb_map (hb_second) - | hb_apply ([&] (const OffsetTo &_) { (this+_).closure (c); }) + | hb_apply ([c, this] (const OffsetTo &_) { (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 &_) { (this+_).collect_glyphs (c); }) + | hb_apply ([c, this] (const OffsetTo &_) { (this+_).collect_glyphs (c); }) ; } @@ -741,7 +742,7 @@ struct LigatureSet { return + hb_iter (ligature) - | hb_map ([&] (const OffsetTo &_) { return (this+_).intersects (glyphs); }) + | hb_map ([this, glyphs] (const OffsetTo &_) { 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 &_) { (this+_).closure (c); }) + | hb_apply ([this, c] (const OffsetTo &_) { (this+_).closure (c); }) ; } void collect_glyphs (hb_collect_glyphs_context_t *c) const { + hb_iter (ligature) - | hb_apply ([&] (const OffsetTo &_) { (this+_).collect_glyphs (c); }) + | hb_apply ([this, c] (const OffsetTo &_) { (this+_).collect_glyphs (c); }) ; } @@ -764,7 +765,7 @@ struct LigatureSet { return + hb_iter (ligature) - | hb_map ([&] (const OffsetTo &_) { return (this+_).would_apply (c); }) + | hb_map ([this, c] (const OffsetTo &_) { 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 &_) -> bool + | hb_map ([this, glyphs] (const OffsetTo &_) { 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 &_) { (this+_).closure (c); }) + | hb_apply ([this, c] (const OffsetTo &_) { (this+_).closure (c); }) ; } @@ -846,7 +847,7 @@ struct LigatureSubstFormat1 + hb_zip (this+coverage, ligatureSet) | hb_map (hb_second) - | hb_apply ([&] (const OffsetTo &_) { (this+_).collect_glyphs (c); }) + | hb_apply ([this, c] (const OffsetTo &_) { (this+_).collect_glyphs (c); }) ; } diff --git a/src/hb-ot-layout-gsubgpos.hh b/src/hb-ot-layout-gsubgpos.hh index a8deb70d4..091930cc2 100644 --- a/src/hb-ot-layout-gsubgpos.hh +++ b/src/hb-ot-layout-gsubgpos.hh @@ -1546,7 +1546,7 @@ struct ContextFormat2 return + hb_enumerate (ruleSet) - | hb_map ([&] (const hb_pair_t &> p) -> bool + | hb_map ([&] (const hb_pair_t &> 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 &> p) -> bool - { return input_class_def.intersects_class (glyphs, p.first) && - (this+p.second).intersects (glyphs, lookup_context); }) + | hb_map ([&] (const hb_pair_t &> 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) diff --git a/src/hb-ot-name-table.hh b/src/hb-ot-name-table.hh index 332f48533..6c75cc398 100644 --- a/src/hb-ot-name-table.hh +++ b/src/hb-ot-name-table.hh @@ -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); diff --git a/src/hb-ot-stat-table.hh b/src/hb-ot-stat-table.hh index 72d377281..228c3ecc1 100644 --- a/src/hb-ot-stat-table.hh +++ b/src/hb-ot-stat-table.hh @@ -289,7 +289,7 @@ struct STAT ; + get_axis_value_offsets () - | hb_map ([&] (const OffsetTo& _) { return hb_addressof (this + _); }) + | hb_map ([this] (const OffsetTo& _) { return hb_addressof (this + _); }) | hb_map (&AxisValue::get_value_name_id) | hb_sink (nameids_to_retain) ; diff --git a/src/hb-ot-var-fvar-table.hh b/src/hb-ot-var-fvar-table.hh index 8b3b38ce9..7df81428f 100644 --- a/src/hb-ot-var-fvar-table.hh +++ b/src/hb-ot-var-fvar-table.hh @@ -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) ; } diff --git a/src/hb-subset-plan.cc b/src/hb-subset-plan.cc index 0c1c7a254..fad75d0b3 100644 --- a/src/hb-subset-plan.cc +++ b/src/hb-subset-plan.cc @@ -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_sink (reverse_glyph_map) diff --git a/src/test-iter.cc b/src/test-iter.cc index c36453d1f..156a5fcad 100644 --- a/src/test-iter.cc +++ b/src/test-iter.cc @@ -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;