[layout] Allocate iters in the context
Can be further optimized, but I think I didn't break anything.
Saves another 3% off Roboto shaping.
diff --git a/src/hb-ot-layout-gpos-table.hh b/src/hb-ot-layout-gpos-table.hh
index dc3f40b..ad0633b 100644
--- a/src/hb-ot-layout-gpos-table.hh
+++ b/src/hb-ot-layout-gpos-table.hh
@@ -684,8 +684,7 @@
unsigned int index = (this+coverage).get_coverage (buffer->cur().codepoint);
if (likely (index == NOT_COVERED)) return TRACE_RETURN (false);
- hb_apply_context_t::skipping_iterator_t skippy_iter;
- skippy_iter.init (c);
+ hb_apply_context_t::skipping_iterator_t &skippy_iter = c->iter_input;
skippy_iter.reset (buffer->idx, 1);
if (!skippy_iter.next ()) return TRACE_RETURN (false);
@@ -755,8 +754,7 @@
unsigned int index = (this+coverage).get_coverage (buffer->cur().codepoint);
if (likely (index == NOT_COVERED)) return TRACE_RETURN (false);
- hb_apply_context_t::skipping_iterator_t skippy_iter;
- skippy_iter.init (c);
+ hb_apply_context_t::skipping_iterator_t &skippy_iter = c->iter_input;
skippy_iter.reset (buffer->idx, 1);
if (!skippy_iter.next ()) return TRACE_RETURN (false);
@@ -906,8 +904,7 @@
const EntryExitRecord &this_record = entryExitRecord[(this+coverage).get_coverage (buffer->cur().codepoint)];
if (!this_record.exitAnchor) return TRACE_RETURN (false);
- hb_apply_context_t::skipping_iterator_t skippy_iter;
- skippy_iter.init (c);
+ hb_apply_context_t::skipping_iterator_t &skippy_iter = c->iter_input;
skippy_iter.reset (buffer->idx, 1);
if (!skippy_iter.next ()) return TRACE_RETURN (false);
@@ -1051,8 +1048,7 @@
if (likely (mark_index == NOT_COVERED)) return TRACE_RETURN (false);
/* now we search backwards for a non-mark glyph */
- hb_apply_context_t::skipping_iterator_t skippy_iter;
- skippy_iter.init (c);
+ hb_apply_context_t::skipping_iterator_t &skippy_iter = c->iter_input;
skippy_iter.reset (buffer->idx, 1);
skippy_iter.set_lookup_props (LookupFlag::IgnoreMarks);
do {
@@ -1157,8 +1153,7 @@
if (likely (mark_index == NOT_COVERED)) return TRACE_RETURN (false);
/* now we search backwards for a non-mark glyph */
- hb_apply_context_t::skipping_iterator_t skippy_iter;
- skippy_iter.init (c);
+ hb_apply_context_t::skipping_iterator_t &skippy_iter = c->iter_input;
skippy_iter.reset (buffer->idx, 1);
skippy_iter.set_lookup_props (LookupFlag::IgnoreMarks);
if (!skippy_iter.prev ()) return TRACE_RETURN (false);
@@ -1275,8 +1270,7 @@
if (likely (mark1_index == NOT_COVERED)) return TRACE_RETURN (false);
/* now we search backwards for a suitable mark glyph until a non-mark glyph */
- hb_apply_context_t::skipping_iterator_t skippy_iter;
- skippy_iter.init (c);
+ hb_apply_context_t::skipping_iterator_t &skippy_iter = c->iter_input;
skippy_iter.reset (buffer->idx, 1);
skippy_iter.set_lookup_props (c->lookup_props & ~LookupFlag::IgnoreFlags);
if (!skippy_iter.prev ()) return TRACE_RETURN (false);
diff --git a/src/hb-ot-layout-gsubgpos-private.hh b/src/hb-ot-layout-gsubgpos-private.hh
index 254abb6..3f99a10 100644
--- a/src/hb-ot-layout-gsubgpos-private.hh
+++ b/src/hb-ot-layout-gsubgpos-private.hh
@@ -469,6 +469,7 @@
unsigned int lookup_props;
const GDEF &gdef;
bool has_glyph_classes;
+ skipping_iterator_t iter_input, iter_context;
unsigned int debug_depth;
@@ -485,13 +486,20 @@
lookup_props (0),
gdef (*hb_ot_layout_from_face (face)->gdef),
has_glyph_classes (gdef.has_glyph_classes ()),
+ iter_input (),
+ iter_context (),
debug_depth (0) {}
inline void set_lookup_mask (hb_mask_t mask) { lookup_mask = mask; }
inline void set_auto_zwj (bool auto_zwj_) { auto_zwj = auto_zwj_; }
inline void set_recurse_func (recurse_func_t func) { recurse_func = func; }
- inline void set_lookup_props (unsigned int lookup_props_) { lookup_props = lookup_props_; }
- inline void set_lookup (const Lookup &l) { lookup_props = l.get_props (); }
+ inline void set_lookup (const Lookup &l) { set_lookup_props (l.get_props ()); }
+ inline void set_lookup_props (unsigned int lookup_props_)
+ {
+ lookup_props = lookup_props_;
+ iter_input.init (this, false);
+ iter_context.init (this, true);
+ }
inline bool
match_properties_mark (hb_codepoint_t glyph,
@@ -704,8 +712,7 @@
hb_buffer_t *buffer = c->buffer;
- hb_apply_context_t::skipping_iterator_t skippy_iter;
- skippy_iter.init (c);
+ hb_apply_context_t::skipping_iterator_t &skippy_iter = c->iter_input;
skippy_iter.reset (buffer->idx, count - 1);
skippy_iter.set_match_func (match_func, match_data, input);
@@ -874,8 +881,7 @@
{
TRACE_APPLY (NULL);
- hb_apply_context_t::skipping_iterator_t skippy_iter;
- skippy_iter.init (c, true);
+ hb_apply_context_t::skipping_iterator_t &skippy_iter = c->iter_context;
skippy_iter.reset (c->buffer->backtrack_len (), count);
skippy_iter.set_match_func (match_func, match_data, backtrack);
@@ -895,8 +901,7 @@
{
TRACE_APPLY (NULL);
- hb_apply_context_t::skipping_iterator_t skippy_iter;
- skippy_iter.init (c, true);
+ hb_apply_context_t::skipping_iterator_t &skippy_iter = c->iter_context;
skippy_iter.reset (c->buffer->idx + offset - 1, count);
skippy_iter.set_match_func (match_func, match_data, lookahead);
diff --git a/src/hb-ot-shape-fallback.cc b/src/hb-ot-shape-fallback.cc
index d17adf5..53274b5 100644
--- a/src/hb-ot-shape-fallback.cc
+++ b/src/hb-ot-shape-fallback.cc
@@ -441,7 +441,7 @@
OT::hb_apply_context_t c (1, font, buffer);
c.set_lookup_mask (plan->kern_mask);
c.set_lookup_props (OT::LookupFlag::IgnoreMarks);
- OT::hb_apply_context_t::skipping_iterator_t skippy_iter;
+ OT::hb_apply_context_t::skipping_iterator_t &skippy_iter = c.iter_input;
skippy_iter.init (&c);
unsigned int count = buffer->len;