diff --git a/src/OT/Layout/Common/Coverage.hh b/src/OT/Layout/Common/Coverage.hh index dc4b440d1..5047fe42f 100644 --- a/src/OT/Layout/Common/Coverage.hh +++ b/src/OT/Layout/Common/Coverage.hh @@ -204,15 +204,17 @@ struct Coverage } } - void intersected_coverage_glyphs (const hb_set_t *glyphs, hb_set_t *intersect_glyphs) const + template + void intersect_set (const hb_set_t &glyphs, IteratorOut &intersect_glyphs) const { switch (u.format) { - case 1: return u.format1.intersected_coverage_glyphs (glyphs, intersect_glyphs); - case 2: return u.format2.intersected_coverage_glyphs (glyphs, intersect_glyphs); + case 1: return u.format1.intersect_set (glyphs, intersect_glyphs); + case 2: return u.format2.intersect_set (glyphs, intersect_glyphs); #ifndef HB_NO_BORING_EXPANSION - case 3: return u.format3.intersected_coverage_glyphs (glyphs, intersect_glyphs); - case 4: return u.format4.intersected_coverage_glyphs (glyphs, intersect_glyphs); + case 3: return u.format3.intersect_set (glyphs, intersect_glyphs); + case 4: return u.format4.intersect_set (glyphs, intersect_glyphs); #endif default:return ; } diff --git a/src/OT/Layout/Common/CoverageFormat1.hh b/src/OT/Layout/Common/CoverageFormat1.hh index 4a1e234e6..28de94b58 100644 --- a/src/OT/Layout/Common/CoverageFormat1.hh +++ b/src/OT/Layout/Common/CoverageFormat1.hh @@ -86,12 +86,14 @@ struct CoverageFormat1_3 bool intersects_coverage (const hb_set_t *glyphs, unsigned int index) const { return glyphs->has (glyphArray[index]); } - void intersected_coverage_glyphs (const hb_set_t *glyphs, hb_set_t *intersect_glyphs) const + template + void intersect_set (const hb_set_t &glyphs, IteratorOut &intersect_glyphs) const { unsigned count = glyphArray.len; for (unsigned i = 0; i < count; i++) - if (glyphs->has (glyphArray[i])) - intersect_glyphs->add (glyphArray[i]); + if (glyphs.has (glyphArray[i])) + intersect_glyphs << glyphArray[i]; } template diff --git a/src/OT/Layout/Common/CoverageFormat2.hh b/src/OT/Layout/Common/CoverageFormat2.hh index c0449e326..98272a37b 100644 --- a/src/OT/Layout/Common/CoverageFormat2.hh +++ b/src/OT/Layout/Common/CoverageFormat2.hh @@ -116,7 +116,7 @@ struct CoverageFormat2_4 bool intersects (const hb_set_t *glyphs) const { return hb_any (+ hb_iter (rangeRecord.as_array ()) - | hb_map ([glyphs] (const RangeRecord &range) { return range.intersects (glyphs); })); + | hb_map ([glyphs] (const RangeRecord &range) { return range.intersects (*glyphs); })); } bool intersects_coverage (const hb_set_t *glyphs, unsigned int index) const { @@ -134,19 +134,21 @@ struct CoverageFormat2_4 if (hb_bsearch_impl (&idx, index, arr.arrayZ, arr.length, sizeof (arr[0]), (int (*)(const void *_key, const void *_item)) cmp)) - return arr.arrayZ[idx].intersects (glyphs); + return arr.arrayZ[idx].intersects (*glyphs); return false; } - void intersected_coverage_glyphs (const hb_set_t *glyphs, hb_set_t *intersect_glyphs) const + template + void intersect_set (const hb_set_t &glyphs, IteratorOut &intersect_glyphs) const { for (const auto& range : rangeRecord.as_array ()) { if (!range.intersects (glyphs)) continue; unsigned last = range.last; for (hb_codepoint_t g = range.first - 1; - glyphs->next (&g) && g <= last;) - intersect_glyphs->add (g); + glyphs.next (&g) && g <= last;) + intersect_glyphs << g; } } diff --git a/src/OT/Layout/Common/RangeRecord.hh b/src/OT/Layout/Common/RangeRecord.hh index 30edf1b0b..a62629fad 100644 --- a/src/OT/Layout/Common/RangeRecord.hh +++ b/src/OT/Layout/Common/RangeRecord.hh @@ -57,8 +57,8 @@ struct RangeRecord return (last - first + 1); } - bool intersects (const hb_set_t *glyphs) const - { return glyphs->intersects (first, last); } + bool intersects (const hb_set_t &glyphs) const + { return glyphs.intersects (first, last); } template bool collect_coverage (set_t *glyphs) const diff --git a/src/OT/Layout/GPOS/SinglePosFormat1.hh b/src/OT/Layout/GPOS/SinglePosFormat1.hh index 1de8a36c4..c0e7d29ce 100644 --- a/src/OT/Layout/GPOS/SinglePosFormat1.hh +++ b/src/OT/Layout/GPOS/SinglePosFormat1.hh @@ -105,7 +105,7 @@ struct SinglePosFormat1 const hb_map_t &glyph_map = *c->plan->glyph_map; hb_set_t intersection; - (this+coverage).intersected_coverage_glyphs (&glyphset, &intersection); + (this+coverage).intersect_set (glyphset, intersection); auto it = + hb_iter (intersection) diff --git a/src/OT/Layout/GSUB/SingleSubstFormat1.hh b/src/OT/Layout/GSUB/SingleSubstFormat1.hh index b57be0ad1..cab36ad8f 100644 --- a/src/OT/Layout/GSUB/SingleSubstFormat1.hh +++ b/src/OT/Layout/GSUB/SingleSubstFormat1.hh @@ -136,7 +136,7 @@ struct SingleSubstFormat1_3 hb_codepoint_t mask = get_mask (); hb_set_t intersection; - (this+coverage).intersected_coverage_glyphs (&glyphset, &intersection); + (this+coverage).intersect_set (glyphset, intersection); auto it = + hb_iter (intersection) diff --git a/src/hb-ot-layout-common.hh b/src/hb-ot-layout-common.hh index 4946002c4..8f741745d 100644 --- a/src/hb-ot-layout-common.hh +++ b/src/hb-ot-layout-common.hh @@ -1786,7 +1786,7 @@ struct ClassDefFormat2_4 for (unsigned int i = 0; i < count; i++) { const auto& range = rangeRecord[i]; - if (range.intersects (glyphs) && range.value) + if (range.intersects (*glyphs) && range.value) return true; } return false; @@ -1814,7 +1814,7 @@ struct ClassDefFormat2_4 /* TODO(iter) Rewrite as dagger. */ const auto *arr = rangeRecord.arrayZ; for (unsigned int i = 0; i < count; i++) - if (arr[i].value == klass && arr[i].intersects (glyphs)) + if (arr[i].value == klass && arr[i].intersects (*glyphs)) return true; return false; } @@ -1889,7 +1889,7 @@ struct ClassDefFormat2_4 intersect_classes->add (0); for (const auto& record : rangeRecord.iter ()) - if (record.intersects (glyphs)) + if (record.intersects (*glyphs)) intersect_classes->add (record.value); } diff --git a/src/hb-ot-layout-gsubgpos.hh b/src/hb-ot-layout-gsubgpos.hh index db50b5cef..29187f3cf 100644 --- a/src/hb-ot-layout-gsubgpos.hh +++ b/src/hb-ot-layout-gsubgpos.hh @@ -1043,7 +1043,7 @@ static inline void intersected_coverage_glyphs (const hb_set_t *glyphs, const vo { Offset16To coverage; coverage = value; - (data+coverage).intersected_coverage_glyphs (glyphs, intersected_glyphs); + (data+coverage).intersect_set (*glyphs, *intersected_glyphs); } @@ -2066,9 +2066,8 @@ struct ContextFormat1_4 void closure (hb_closure_context_t *c) const { - hb_set_t* cur_active_glyphs = &c->push_cur_active_glyphs (); - get_coverage ().intersected_coverage_glyphs (&c->previous_parent_active_glyphs (), - cur_active_glyphs); + hb_set_t& cur_active_glyphs = c->push_cur_active_glyphs (); + get_coverage ().intersect_set (c->previous_parent_active_glyphs (), cur_active_glyphs); struct ContextClosureLookupContext lookup_context = { {intersects_glyph, intersected_glyph}, @@ -2209,7 +2208,7 @@ struct ContextFormat2_5 }; hb_set_t retained_coverage_glyphs; - (this+coverage).intersected_coverage_glyphs (glyphs, &retained_coverage_glyphs); + (this+coverage).intersect_set (*glyphs, retained_coverage_glyphs); hb_set_t coverage_glyph_classes; class_def.intersected_classes (&retained_coverage_glyphs, &coverage_glyph_classes); @@ -2235,8 +2234,8 @@ struct ContextFormat2_5 if (!(this+coverage).intersects (c->glyphs)) return; - hb_set_t* cur_active_glyphs = &c->push_cur_active_glyphs (); - get_coverage ().intersected_coverage_glyphs (&c->previous_parent_active_glyphs (), + hb_set_t& cur_active_glyphs = c->push_cur_active_glyphs (); + get_coverage ().intersect_set (c->previous_parent_active_glyphs (), cur_active_glyphs); const ClassDef &class_def = this+classDef; @@ -2381,7 +2380,7 @@ struct ContextFormat2_5 const hb_set_t* glyphset = c->plan->glyphset_gsub (); hb_set_t retained_coverage_glyphs; - (this+coverage).intersected_coverage_glyphs (glyphset, &retained_coverage_glyphs); + (this+coverage).intersect_set (*glyphset, retained_coverage_glyphs); hb_set_t coverage_glyph_classes; (this+classDef).intersected_classes (&retained_coverage_glyphs, &coverage_glyph_classes); @@ -2468,8 +2467,8 @@ struct ContextFormat3 if (!(this+coverageZ[0]).intersects (c->glyphs)) return; - hb_set_t* cur_active_glyphs = &c->push_cur_active_glyphs (); - get_coverage ().intersected_coverage_glyphs (&c->previous_parent_active_glyphs (), + hb_set_t& cur_active_glyphs = c->push_cur_active_glyphs (); + get_coverage ().intersect_set (c->previous_parent_active_glyphs (), cur_active_glyphs); @@ -3124,8 +3123,8 @@ struct ChainContextFormat1_4 void closure (hb_closure_context_t *c) const { - hb_set_t* cur_active_glyphs = &c->push_cur_active_glyphs (); - get_coverage ().intersected_coverage_glyphs (&c->previous_parent_active_glyphs (), + hb_set_t& cur_active_glyphs = c->push_cur_active_glyphs (); + get_coverage ().intersect_set (c->previous_parent_active_glyphs (), cur_active_glyphs); struct ChainContextClosureLookupContext lookup_context = { @@ -3269,7 +3268,7 @@ struct ChainContextFormat2_5 }; hb_set_t retained_coverage_glyphs; - (this+coverage).intersected_coverage_glyphs (glyphs, &retained_coverage_glyphs); + (this+coverage).intersect_set (*glyphs, retained_coverage_glyphs); hb_set_t coverage_glyph_classes; input_class_def.intersected_classes (&retained_coverage_glyphs, &coverage_glyph_classes); @@ -3294,8 +3293,8 @@ struct ChainContextFormat2_5 if (!(this+coverage).intersects (c->glyphs)) return; - hb_set_t* cur_active_glyphs = &c->push_cur_active_glyphs (); - get_coverage ().intersected_coverage_glyphs (&c->previous_parent_active_glyphs (), + hb_set_t& cur_active_glyphs = c->push_cur_active_glyphs (); + get_coverage ().intersect_set (c->previous_parent_active_glyphs (), cur_active_glyphs); @@ -3479,7 +3478,7 @@ struct ChainContextFormat2_5 const hb_set_t* glyphset = c->plan->glyphset_gsub (); hb_set_t retained_coverage_glyphs; - (this+coverage).intersected_coverage_glyphs (glyphset, &retained_coverage_glyphs); + (this+coverage).intersect_set (*glyphset, retained_coverage_glyphs); hb_set_t coverage_glyph_classes; (this+inputClassDef).intersected_classes (&retained_coverage_glyphs, &coverage_glyph_classes); @@ -3590,8 +3589,8 @@ struct ChainContextFormat3 if (!(this+input[0]).intersects (c->glyphs)) return; - hb_set_t* cur_active_glyphs = &c->push_cur_active_glyphs (); - get_coverage ().intersected_coverage_glyphs (&c->previous_parent_active_glyphs (), + hb_set_t& cur_active_glyphs = c->push_cur_active_glyphs (); + get_coverage ().intersect_set (c->previous_parent_active_glyphs (), cur_active_glyphs);