diff --git a/src/hb-open-type-private.hh b/src/hb-open-type-private.hh index e5c4c0dc3..aeb330291 100644 --- a/src/hb-open-type-private.hh +++ b/src/hb-open-type-private.hh @@ -165,6 +165,7 @@ struct hb_dispatch_context_t typedef Return return_t; template inline bool may_dispatch (const T *obj, const F *format) { return true; } + static return_t no_dispatch_return_value (void) { return Context::default_return_value (); } }; @@ -203,6 +204,7 @@ struct hb_sanitize_context_t : template inline return_t dispatch (const T &obj) { return obj.sanitize (this); } static return_t default_return_value (void) { return true; } + static return_t no_dispatch_return_value (void) { return false; } bool stop_sublookup_iteration (const return_t r) const { return !r; } inline void init (hb_blob_t *b) diff --git a/src/hb-ot-layout-gpos-table.hh b/src/hb-ot-layout-gpos-table.hh index 286253d70..ca98cb7a5 100644 --- a/src/hb-ot-layout-gpos-table.hh +++ b/src/hb-ot-layout-gpos-table.hh @@ -548,7 +548,7 @@ struct SinglePos inline typename context_t::return_t dispatch (context_t *c) const { TRACE_DISPATCH (this, u.format); - if (unlikely (!c->may_dispatch (this, &u.format))) return_trace (c->default_return_value ()); + if (unlikely (!c->may_dispatch (this, &u.format))) return_trace (c->no_dispatch_return_value ()); switch (u.format) { case 1: return_trace (c->dispatch (u.format1)); case 2: return_trace (c->dispatch (u.format2)); @@ -843,7 +843,7 @@ struct PairPos inline typename context_t::return_t dispatch (context_t *c) const { TRACE_DISPATCH (this, u.format); - if (unlikely (!c->may_dispatch (this, &u.format))) return_trace (c->default_return_value ()); + if (unlikely (!c->may_dispatch (this, &u.format))) return_trace (c->no_dispatch_return_value ()); switch (u.format) { case 1: return_trace (c->dispatch (u.format1)); case 2: return_trace (c->dispatch (u.format2)); @@ -1024,7 +1024,7 @@ struct CursivePos inline typename context_t::return_t dispatch (context_t *c) const { TRACE_DISPATCH (this, u.format); - if (unlikely (!c->may_dispatch (this, &u.format))) return_trace (c->default_return_value ()); + if (unlikely (!c->may_dispatch (this, &u.format))) return_trace (c->no_dispatch_return_value ()); switch (u.format) { case 1: return_trace (c->dispatch (u.format1)); default:return_trace (c->default_return_value ()); @@ -1120,7 +1120,7 @@ struct MarkBasePos inline typename context_t::return_t dispatch (context_t *c) const { TRACE_DISPATCH (this, u.format); - if (unlikely (!c->may_dispatch (this, &u.format))) return_trace (c->default_return_value ()); + if (unlikely (!c->may_dispatch (this, &u.format))) return_trace (c->no_dispatch_return_value ()); switch (u.format) { case 1: return_trace (c->dispatch (u.format1)); default:return_trace (c->default_return_value ()); @@ -1238,7 +1238,7 @@ struct MarkLigPos inline typename context_t::return_t dispatch (context_t *c) const { TRACE_DISPATCH (this, u.format); - if (unlikely (!c->may_dispatch (this, &u.format))) return_trace (c->default_return_value ()); + if (unlikely (!c->may_dispatch (this, &u.format))) return_trace (c->no_dispatch_return_value ()); switch (u.format) { case 1: return_trace (c->dispatch (u.format1)); default:return_trace (c->default_return_value ()); @@ -1353,7 +1353,7 @@ struct MarkMarkPos inline typename context_t::return_t dispatch (context_t *c) const { TRACE_DISPATCH (this, u.format); - if (unlikely (!c->may_dispatch (this, &u.format))) return_trace (c->default_return_value ()); + if (unlikely (!c->may_dispatch (this, &u.format))) return_trace (c->no_dispatch_return_value ()); switch (u.format) { case 1: return_trace (c->dispatch (u.format1)); default:return_trace (c->default_return_value ()); @@ -1404,8 +1404,7 @@ struct PosLookupSubTable inline typename context_t::return_t dispatch (context_t *c, unsigned int lookup_type) const { TRACE_DISPATCH (this, lookup_type); - /* The sub_format passed to may_dispatch is unnecessary but harmless. */ - if (unlikely (!c->may_dispatch (this, &u.sub_format))) return_trace (c->default_return_value ()); + if (unlikely (!c->may_dispatch (this, &u.sub_format))) return_trace (c->no_dispatch_return_value ()); switch (lookup_type) { case Single: return_trace (u.single.dispatch (c)); case Pair: return_trace (u.pair.dispatch (c)); diff --git a/src/hb-ot-layout-gsub-table.hh b/src/hb-ot-layout-gsub-table.hh index c578254d4..eebc87b4c 100644 --- a/src/hb-ot-layout-gsub-table.hh +++ b/src/hb-ot-layout-gsub-table.hh @@ -225,7 +225,7 @@ struct SingleSubst inline typename context_t::return_t dispatch (context_t *c) const { TRACE_DISPATCH (this, u.format); - if (unlikely (!c->may_dispatch (this, &u.format))) return_trace (c->default_return_value ()); + if (unlikely (!c->may_dispatch (this, &u.format))) return_trace (c->no_dispatch_return_value ()); switch (u.format) { case 1: return_trace (c->dispatch (u.format1)); case 2: return_trace (c->dispatch (u.format2)); @@ -418,7 +418,7 @@ struct MultipleSubst inline typename context_t::return_t dispatch (context_t *c) const { TRACE_DISPATCH (this, u.format); - if (unlikely (!c->may_dispatch (this, &u.format))) return_trace (c->default_return_value ()); + if (unlikely (!c->may_dispatch (this, &u.format))) return_trace (c->no_dispatch_return_value ()); switch (u.format) { case 1: return_trace (c->dispatch (u.format1)); default:return_trace (c->default_return_value ()); @@ -562,7 +562,7 @@ struct AlternateSubst inline typename context_t::return_t dispatch (context_t *c) const { TRACE_DISPATCH (this, u.format); - if (unlikely (!c->may_dispatch (this, &u.format))) return_trace (c->default_return_value ()); + if (unlikely (!c->may_dispatch (this, &u.format))) return_trace (c->no_dispatch_return_value ()); switch (u.format) { case 1: return_trace (c->dispatch (u.format1)); default:return_trace (c->default_return_value ()); @@ -878,7 +878,7 @@ struct LigatureSubst inline typename context_t::return_t dispatch (context_t *c) const { TRACE_DISPATCH (this, u.format); - if (unlikely (!c->may_dispatch (this, &u.format))) return_trace (c->default_return_value ()); + if (unlikely (!c->may_dispatch (this, &u.format))) return_trace (c->no_dispatch_return_value ()); switch (u.format) { case 1: return_trace (c->dispatch (u.format1)); default:return_trace (c->default_return_value ()); @@ -1035,7 +1035,7 @@ struct ReverseChainSingleSubst inline typename context_t::return_t dispatch (context_t *c) const { TRACE_DISPATCH (this, u.format); - if (unlikely (!c->may_dispatch (this, &u.format))) return_trace (c->default_return_value ()); + if (unlikely (!c->may_dispatch (this, &u.format))) return_trace (c->no_dispatch_return_value ()); switch (u.format) { case 1: return_trace (c->dispatch (u.format1)); default:return_trace (c->default_return_value ()); @@ -1074,8 +1074,7 @@ struct SubstLookupSubTable inline typename context_t::return_t dispatch (context_t *c, unsigned int lookup_type) const { TRACE_DISPATCH (this, lookup_type); - /* The sub_format passed to may_dispatch is unnecessary but harmless. */ - if (unlikely (!c->may_dispatch (this, &u.sub_format))) return_trace (c->default_return_value ()); + if (unlikely (!c->may_dispatch (this, &u.sub_format))) return_trace (c->no_dispatch_return_value ()); switch (lookup_type) { case Single: return_trace (u.single.dispatch (c)); case Multiple: return_trace (u.multiple.dispatch (c)); diff --git a/src/hb-ot-layout-gsubgpos-private.hh b/src/hb-ot-layout-gsubgpos-private.hh index 65e39a607..2a9f444d5 100644 --- a/src/hb-ot-layout-gsubgpos-private.hh +++ b/src/hb-ot-layout-gsubgpos-private.hh @@ -1505,7 +1505,7 @@ struct Context inline typename context_t::return_t dispatch (context_t *c) const { TRACE_DISPATCH (this, u.format); - if (unlikely (!c->may_dispatch (this, &u.format))) return_trace (c->default_return_value ()); + if (unlikely (!c->may_dispatch (this, &u.format))) return_trace (c->no_dispatch_return_value ()); switch (u.format) { case 1: return_trace (c->dispatch (u.format1)); case 2: return_trace (c->dispatch (u.format2)); @@ -2120,7 +2120,7 @@ struct ChainContext inline typename context_t::return_t dispatch (context_t *c) const { TRACE_DISPATCH (this, u.format); - if (unlikely (!c->may_dispatch (this, &u.format))) return_trace (c->default_return_value ()); + if (unlikely (!c->may_dispatch (this, &u.format))) return_trace (c->no_dispatch_return_value ()); switch (u.format) { case 1: return_trace (c->dispatch (u.format1)); case 2: return_trace (c->dispatch (u.format2)); @@ -2156,7 +2156,7 @@ struct ExtensionFormat1 inline typename context_t::return_t dispatch (context_t *c) const { TRACE_DISPATCH (this, format); - if (unlikely (!c->may_dispatch (this, this))) return_trace (c->default_return_value ()); + if (unlikely (!c->may_dispatch (this, this))) return_trace (c->no_dispatch_return_value ()); return_trace (get_subtable ().dispatch (c, get_type ())); } @@ -2201,7 +2201,7 @@ struct Extension inline typename context_t::return_t dispatch (context_t *c) const { TRACE_DISPATCH (this, u.format); - if (unlikely (!c->may_dispatch (this, &u.format))) return_trace (c->default_return_value ()); + if (unlikely (!c->may_dispatch (this, &u.format))) return_trace (c->no_dispatch_return_value ()); switch (u.format) { case 1: return_trace (u.format1.dispatch (c)); default:return_trace (c->default_return_value ());