From 8e36ccfd4f076888076ca176c055c18104af03b6 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 17 Feb 2015 19:15:34 +0300 Subject: [PATCH] [layout] Use dispatch() for add_coverage() --- src/hb-ot-layout-gpos-table.hh | 12 ++---------- src/hb-ot-layout-gsub-table.hh | 12 ++---------- src/hb-ot-layout-gsubgpos-private.hh | 12 ++++++++++-- 3 files changed, 14 insertions(+), 22 deletions(-) diff --git a/src/hb-ot-layout-gpos-table.hh b/src/hb-ot-layout-gpos-table.hh index b804bdd8f..8ae4c8319 100644 --- a/src/hb-ot-layout-gpos-table.hh +++ b/src/hb-ot-layout-gpos-table.hh @@ -1506,16 +1506,8 @@ struct PosLookup : Lookup template inline void add_coverage (set_t *glyphs) const { - hb_get_coverage_context_t c; - const Coverage *last = NULL; - unsigned int count = get_subtable_count (); - for (unsigned int i = 0; i < count; i++) { - const Coverage *coverage = &get_subtable (i).dispatch (&c, get_type ()); - if (coverage != last) { - coverage->add_coverage (glyphs); - last = coverage; - } - } + hb_add_coverage_context_t c (glyphs); + dispatch (&c); } inline bool apply_once (hb_apply_context_t *c) const diff --git a/src/hb-ot-layout-gsub-table.hh b/src/hb-ot-layout-gsub-table.hh index c1d64b544..ed8604f29 100644 --- a/src/hb-ot-layout-gsub-table.hh +++ b/src/hb-ot-layout-gsub-table.hh @@ -1200,16 +1200,8 @@ struct SubstLookup : Lookup template inline void add_coverage (set_t *glyphs) const { - hb_get_coverage_context_t c; - const Coverage *last = NULL; - unsigned int count = get_subtable_count (); - for (unsigned int i = 0; i < count; i++) { - const Coverage *coverage = &get_subtable (i).dispatch (&c, get_type ()); - if (coverage != last) { - coverage->add_coverage (glyphs); - last = coverage; - } - } + hb_add_coverage_context_t c (glyphs); + dispatch (&c); } inline bool would_apply (hb_would_apply_context_t *c, diff --git a/src/hb-ot-layout-gsubgpos-private.hh b/src/hb-ot-layout-gsubgpos-private.hh index 2751c8249..b060a6920 100644 --- a/src/hb-ot-layout-gsubgpos-private.hh +++ b/src/hb-ot-layout-gsubgpos-private.hh @@ -238,7 +238,8 @@ struct hb_collect_glyphs_context_t #define HB_DEBUG_GET_COVERAGE (HB_DEBUG+0) #endif -struct hb_get_coverage_context_t +template +struct hb_add_coverage_context_t { inline const char *get_name (void) { return "GET_COVERAGE"; } static const unsigned int max_debug_depth = HB_DEBUG_GET_COVERAGE; @@ -248,10 +249,17 @@ struct hb_get_coverage_context_t template inline return_t dispatch (const T &obj) { return obj.get_coverage (); } static return_t default_return_value (void) { return Null(Coverage); } + bool stop_sublookup_iteration (return_t r) const + { + r.add_coverage (set); + return false; + } - hb_get_coverage_context_t (void) : + hb_add_coverage_context_t (set_t *set_) : + set (set_), debug_depth (0) {} + set_t *set; unsigned int debug_depth; };