From 6d051f4018e21ce1ec93fe4876c4a15819d0940a Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Fri, 8 Jul 2022 14:08:51 -0600 Subject: [PATCH] [layout] Simplify StructAfter<> usage --- src/hb-ot-layout-gsubgpos.hh | 107 ++++++++++++++++++----------------- 1 file changed, 54 insertions(+), 53 deletions(-) diff --git a/src/hb-ot-layout-gsubgpos.hh b/src/hb-ot-layout-gsubgpos.hh index e53a0206a..af90a5eab 100644 --- a/src/hb-ot-layout-gsubgpos.hh +++ b/src/hb-ot-layout-gsubgpos.hh @@ -2709,8 +2709,8 @@ struct ChainRule { bool intersects (const hb_set_t *glyphs, ChainContextClosureLookupContext &lookup_context) const { - const auto &input = StructAfter> (backtrack); - const auto &lookahead = StructAfter> (input); + const auto &input = StructAfter (backtrack); + const auto &lookahead = StructAfter (input); return chain_context_intersects (glyphs, backtrack.len, backtrack.arrayZ, input.lenP1, input.arrayZ, @@ -2723,9 +2723,9 @@ struct ChainRule { if (unlikely (c->lookup_limit_exceeded ())) return; - const auto &input = StructAfter> (backtrack); - const auto &lookahead = StructAfter> (input); - const auto &lookup = StructAfter> (lookahead); + const auto &input = StructAfter (backtrack); + const auto &lookahead = StructAfter (input); + const auto &lookup = StructAfter (lookahead); chain_context_closure_lookup (c, backtrack.len, backtrack.arrayZ, input.lenP1, input.arrayZ, @@ -2741,18 +2741,18 @@ struct ChainRule if (unlikely (c->lookup_limit_exceeded ())) return; if (!intersects (c->glyphs, lookup_context)) return; - const auto &input = StructAfter> (backtrack); - const auto &lookahead = StructAfter> (input); - const auto &lookup = StructAfter> (lookahead); + const auto &input = StructAfter (backtrack); + const auto &lookahead = StructAfter (input); + const auto &lookup = StructAfter (lookahead); recurse_lookups (c, lookup.len, lookup.arrayZ); } void collect_glyphs (hb_collect_glyphs_context_t *c, ChainContextCollectGlyphsLookupContext &lookup_context) const { - const auto &input = StructAfter> (backtrack); - const auto &lookahead = StructAfter> (input); - const auto &lookup = StructAfter> (lookahead); + const auto &input = StructAfter (backtrack); + const auto &lookahead = StructAfter (input); + const auto &lookup = StructAfter (lookahead); chain_context_collect_glyphs_lookup (c, backtrack.len, backtrack.arrayZ, input.lenP1, input.arrayZ, @@ -2764,9 +2764,9 @@ struct ChainRule bool would_apply (hb_would_apply_context_t *c, ChainContextApplyLookupContext &lookup_context) const { - const auto &input = StructAfter> (backtrack); - const auto &lookahead = StructAfter> (input); - const auto &lookup = StructAfter> (lookahead); + const auto &input = StructAfter (backtrack); + const auto &lookahead = StructAfter (input); + const auto &lookup = StructAfter (lookahead); return chain_context_would_apply_lookup (c, backtrack.len, backtrack.arrayZ, input.lenP1, input.arrayZ, @@ -2777,9 +2777,9 @@ struct ChainRule bool apply (hb_ot_apply_context_t *c, ChainContextApplyLookupContext &lookup_context) const { TRACE_APPLY (this); - const auto &input = StructAfter> (backtrack); - const auto &lookahead = StructAfter> (input); - const auto &lookup = StructAfter> (lookahead); + const auto &input = StructAfter (backtrack); + const auto &lookahead = StructAfter (input); + const auto &lookup = StructAfter (lookahead); return_trace (chain_context_apply_lookup (c, backtrack.len, backtrack.arrayZ, input.lenP1, input.arrayZ, @@ -2812,22 +2812,22 @@ struct ChainRule serialize_array (c, backtrack.len, + backtrack.iter () | hb_map (mapping)); - const auto &input = StructAfter> (backtrack); + const auto &input = StructAfter (backtrack); if (input_map) mapping = input_map; serialize_array (c, input.lenP1, + input.iter () | hb_map (mapping)); - const auto &lookahead = StructAfter> (input); + const auto &lookahead = StructAfter (input); if (lookahead_map) mapping = lookahead_map; serialize_array (c, lookahead.len, + lookahead.iter () | hb_map (mapping)); - const auto &lookupRecord = StructAfter> (lookahead); + const auto &lookup = StructAfter (lookahead); - HBUINT16* lookupCount = c->embed (&(lookupRecord.len)); + HBUINT16* lookupCount = c->embed (&(lookup.len)); if (!lookupCount) return_trace (false); - unsigned count = serialize_lookuprecord_array (c, lookupRecord.as_array (), lookup_map); + unsigned count = serialize_lookuprecord_array (c, lookup.as_array (), lookup_map); return_trace (c->check_assign (*lookupCount, count, HB_SERIALIZE_ERROR_INT_OVERFLOW)); } @@ -2839,8 +2839,8 @@ struct ChainRule { TRACE_SUBSET (this); - const auto &input = StructAfter> (backtrack); - const auto &lookahead = StructAfter> (input); + const auto &input = StructAfter (backtrack); + const auto &lookahead = StructAfter (input); if (!backtrack_map) { @@ -2869,11 +2869,11 @@ struct ChainRule { TRACE_SANITIZE (this); if (!backtrack.sanitize (c)) return_trace (false); - const auto &input = StructAfter> (backtrack); + const auto &input = StructAfter (backtrack); if (!input.sanitize (c)) return_trace (false); - const auto &lookahead = StructAfter> (input); + const auto &lookahead = StructAfter (input); if (!lookahead.sanitize (c)) return_trace (false); - const auto &lookup = StructAfter> (lookahead); + const auto &lookup = StructAfter (lookahead); return_trace (lookup.sanitize (c)); } @@ -3467,12 +3467,12 @@ struct ChainContextFormat3 { bool intersects (const hb_set_t *glyphs) const { - const auto &input = StructAfter> (backtrack); + const auto &input = StructAfter (backtrack); if (!(this+input[0]).intersects (glyphs)) return false; - const auto &lookahead = StructAfter> (input); + const auto &lookahead = StructAfter (input); struct ChainContextClosureLookupContext lookup_context = { {intersects_coverage, intersected_coverage_glyphs}, ContextFormat::CoverageBasedContext, @@ -3490,7 +3490,7 @@ struct ChainContextFormat3 void closure (hb_closure_context_t *c) const { - const auto &input = StructAfter> (backtrack); + const auto &input = StructAfter (backtrack); if (!(this+input[0]).intersects (c->glyphs)) return; @@ -3500,8 +3500,8 @@ struct ChainContextFormat3 cur_active_glyphs); - const auto &lookahead = StructAfter> (input); - const auto &lookup = StructAfter> (lookahead); + const auto &lookahead = StructAfter (input); + const auto &lookup = StructAfter (lookahead); struct ChainContextClosureLookupContext lookup_context = { {intersects_coverage, intersected_coverage_glyphs}, ContextFormat::CoverageBasedContext, @@ -3522,9 +3522,9 @@ struct ChainContextFormat3 if (!intersects (c->glyphs)) return; - const auto &input = StructAfter> (backtrack); - const auto &lookahead = StructAfter> (input); - const auto &lookup = StructAfter> (lookahead); + const auto &input = StructAfter (backtrack); + const auto &lookahead = StructAfter (input); + const auto &lookup = StructAfter (lookahead); recurse_lookups (c, lookup.len, lookup.arrayZ); } @@ -3532,12 +3532,13 @@ struct ChainContextFormat3 void collect_glyphs (hb_collect_glyphs_context_t *c) const { - const auto &input = StructAfter> (backtrack); + const auto &input = StructAfter (backtrack); (this+input[0]).collect_coverage (c->input); - const auto &lookahead = StructAfter> (input); - const auto &lookup = StructAfter> (lookahead); + const auto &lookahead = StructAfter (input); + const auto &lookup = StructAfter (lookahead); + struct ChainContextCollectGlyphsLookupContext lookup_context = { {collect_coverage}, {this, this, this} @@ -3552,9 +3553,9 @@ struct ChainContextFormat3 bool would_apply (hb_would_apply_context_t *c) const { - const auto &input = StructAfter> (backtrack); - const auto &lookahead = StructAfter> (input); - const auto &lookup = StructAfter> (lookahead); + const auto &input = StructAfter (backtrack); + const auto &lookahead = StructAfter (input); + const auto &lookup = StructAfter (lookahead); struct ChainContextApplyLookupContext lookup_context = { {{match_coverage, match_coverage, match_coverage}}, {this, this, this} @@ -3568,20 +3569,20 @@ struct ChainContextFormat3 const Coverage &get_coverage () const { - const auto &input = StructAfter> (backtrack); + const auto &input = StructAfter (backtrack); return this+input[0]; } bool apply (hb_ot_apply_context_t *c) const { TRACE_APPLY (this); - const auto &input = StructAfter> (backtrack); + const auto &input = StructAfter (backtrack); unsigned int index = (this+input[0]).get_coverage (c->buffer->cur().codepoint); if (likely (index == NOT_COVERED)) return_trace (false); - const auto &lookahead = StructAfter> (input); - const auto &lookup = StructAfter> (lookahead); + const auto &lookahead = StructAfter (input); + const auto &lookup = StructAfter (lookahead); struct ChainContextApplyLookupContext lookup_context = { {{match_coverage, match_coverage, match_coverage}}, {this, this, this} @@ -3623,21 +3624,21 @@ struct ChainContextFormat3 if (!serialize_coverage_offsets (c, backtrack.iter (), this)) return_trace (false); - const auto &input = StructAfter> (backtrack); + const auto &input = StructAfter (backtrack); if (!serialize_coverage_offsets (c, input.iter (), this)) return_trace (false); - const auto &lookahead = StructAfter> (input); + const auto &lookahead = StructAfter (input); if (!serialize_coverage_offsets (c, lookahead.iter (), this)) return_trace (false); - const auto &lookupRecord = StructAfter> (lookahead); + const auto &lookup = StructAfter (lookahead); const hb_map_t *lookup_map = c->table_tag == HB_OT_TAG_GSUB ? c->plan->gsub_lookups : c->plan->gpos_lookups; - HBUINT16 *lookupCount = c->serializer->copy (lookupRecord.len); + HBUINT16 *lookupCount = c->serializer->copy (lookup.len); if (!lookupCount) return_trace (false); - unsigned count = serialize_lookuprecord_array (c->serializer, lookupRecord.as_array (), lookup_map); + unsigned count = serialize_lookuprecord_array (c->serializer, lookup.as_array (), lookup_map); return_trace (c->serializer->check_assign (*lookupCount, count, HB_SERIALIZE_ERROR_INT_OVERFLOW)); } @@ -3645,12 +3646,12 @@ struct ChainContextFormat3 { TRACE_SANITIZE (this); if (!backtrack.sanitize (c, this)) return_trace (false); - const auto &input = StructAfter> (backtrack); + const auto &input = StructAfter (backtrack); if (!input.sanitize (c, this)) return_trace (false); if (!input.len) return_trace (false); /* To be consistent with Context. */ - const auto &lookahead = StructAfter> (input); + const auto &lookahead = StructAfter (input); if (!lookahead.sanitize (c, this)) return_trace (false); - const auto &lookup = StructAfter> (lookahead); + const auto &lookup = StructAfter (lookahead); return_trace (lookup.sanitize (c)); }