From 4c4e8f0e754b79ac6190d21878eaaf0b790c7579 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Sat, 24 Nov 2012 01:13:20 -0500 Subject: [PATCH] [OTLayout] Reuse apply context for recursion --- src/hb-ot-layout-gpos-table.hh | 7 ++++++- src/hb-ot-layout-gsub-table.hh | 7 ++++++- src/hb-ot-layout-gsubgpos-private.hh | 8 ++++---- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/hb-ot-layout-gpos-table.hh b/src/hb-ot-layout-gpos-table.hh index 873060ff3..e0b8913d6 100644 --- a/src/hb-ot-layout-gpos-table.hh +++ b/src/hb-ot-layout-gpos-table.hh @@ -1537,8 +1537,13 @@ inline bool PosLookup::apply_recurse_func (hb_apply_context_t *c, unsigned int l { const GPOS &gpos = *(hb_ot_layout_from_face (c->face)->gpos); const PosLookup &l = gpos.get_lookup (lookup_index); + unsigned int saved_lookup_props = c->lookup_props; + unsigned int saved_property = c->property; c->set_lookup (l); - return l.apply_once (c); + bool ret = l.apply_once (c); + c->lookup_props = saved_lookup_props; + c->property = saved_property; + return ret; } diff --git a/src/hb-ot-layout-gsub-table.hh b/src/hb-ot-layout-gsub-table.hh index 690b2d525..ddbb3b5eb 100644 --- a/src/hb-ot-layout-gsub-table.hh +++ b/src/hb-ot-layout-gsub-table.hh @@ -1402,8 +1402,13 @@ inline bool SubstLookup::apply_recurse_func (hb_apply_context_t *c, unsigned int { const GSUB &gsub = *(hb_ot_layout_from_face (c->face)->gsub); const SubstLookup &l = gsub.get_lookup (lookup_index); + unsigned int saved_lookup_props = c->lookup_props; + unsigned int saved_property = c->property; c->set_lookup (l); - return l.apply_once (c); + bool ret = l.apply_once (c); + c->lookup_props = saved_lookup_props; + c->property = saved_property; + return ret; } diff --git a/src/hb-ot-layout-gsubgpos-private.hh b/src/hb-ot-layout-gsubgpos-private.hh index 00a4bd4c6..0b1bc68bb 100644 --- a/src/hb-ot-layout-gsubgpos-private.hh +++ b/src/hb-ot-layout-gsubgpos-private.hh @@ -233,10 +233,10 @@ struct hb_apply_context_t if (unlikely (nesting_level_left == 0 || !recurse_func)) return default_return_value (); - /* TODO Reuse context. */ - hb_apply_context_t new_c (*this); - new_c.nesting_level_left--; - return recurse_func (&new_c, lookup_index); + nesting_level_left--; + recurse_func (this, lookup_index); + nesting_level_left++; + return default_return_value (); } hb_font_t *font;