From 06175b71433bc42edc07d342e6354035e37fb5fd Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 15 Jun 2021 14:33:27 -0600 Subject: [PATCH] Remove unneeded buffer clear_output / remove_output calls Made sure clear_output is always paired with swap_buffers. Trying to see if we can move towards RAII-like buffer iterators instead of the buffer keeping an iterator internally. --- src/hb-buffer.cc | 10 ---------- src/hb-buffer.hh | 1 - src/hb-ot-layout.cc | 12 ++++-------- src/hb-ot-shape.cc | 3 +-- 4 files changed, 5 insertions(+), 21 deletions(-) diff --git a/src/hb-buffer.cc b/src/hb-buffer.cc index b125e1cea..5e728b05a 100644 --- a/src/hb-buffer.cc +++ b/src/hb-buffer.cc @@ -281,16 +281,6 @@ hb_buffer_t::add_info (const hb_glyph_info_t &glyph_info) } -void -hb_buffer_t::remove_output () -{ - have_output = false; - have_positions = false; - - out_len = 0; - out_info = info; -} - void hb_buffer_t::clear_output () { diff --git a/src/hb-buffer.hh b/src/hb-buffer.hh index 33d6e6c66..67429df23 100644 --- a/src/hb-buffer.hh +++ b/src/hb-buffer.hh @@ -209,7 +209,6 @@ struct hb_buffer_t HB_INTERNAL void guess_segment_properties (); HB_INTERNAL void swap_buffers (); - HB_INTERNAL void remove_output (); HB_INTERNAL void clear_output (); HB_INTERNAL void clear_positions (); diff --git a/src/hb-ot-layout.cc b/src/hb-ot-layout.cc index 97d2971be..98b4aa641 100644 --- a/src/hb-ot-layout.cc +++ b/src/hb-ot-layout.cc @@ -1857,8 +1857,9 @@ apply_string (OT::hb_ot_apply_context_t *c, if (likely (!lookup.is_reverse ())) { /* in/out forward substitution/positioning */ - if (Proxy::table_index == 0u) + if (!Proxy::inplace) buffer->clear_output (); + buffer->idx = 0; bool ret; @@ -1874,10 +1875,7 @@ apply_string (OT::hb_ot_apply_context_t *c, else { /* in-place backward substitution/positioning */ - if (Proxy::table_index == 0u) - buffer->remove_output (); buffer->idx = buffer->len - 1; - apply_backward (c, accel); } } @@ -1893,7 +1891,8 @@ inline void hb_ot_map_t::apply (const Proxy &proxy, OT::hb_ot_apply_context_t c (table_index, font, buffer); c.set_recurse_func (Proxy::Lookup::apply_recurse_func); - for (unsigned int stage_index = 0; stage_index < stages[table_index].length; stage_index++) { + for (unsigned int stage_index = 0; stage_index < stages[table_index].length; stage_index++) + { const stage_map_t *stage = &stages[table_index][stage_index]; for (; i < stage->last_lookup; i++) { @@ -1915,10 +1914,7 @@ inline void hb_ot_map_t::apply (const Proxy &proxy, } if (stage->pause_func) - { - buffer->clear_output (); stage->pause_func (plan, font, buffer); - } } } diff --git a/src/hb-ot-shape.cc b/src/hb-ot-shape.cc index 4fe148d67..e27094a1d 100644 --- a/src/hb-ot-shape.cc +++ b/src/hb-ot-shape.cc @@ -551,6 +551,7 @@ hb_insert_dotted_circle (hb_buffer_t *buffer, hb_font_t *font) info.cluster = buffer->cur().cluster; info.mask = buffer->cur().mask; (void) buffer->output_info (info); + buffer->swap_buffers (); } @@ -1127,8 +1128,6 @@ hb_ot_shape_internal (hb_ot_shape_context_t *c) _hb_buffer_allocate_unicode_vars (c->buffer); - c->buffer->clear_output (); - hb_ot_shape_initialize_masks (c); hb_set_unicode_props (c->buffer); hb_insert_dotted_circle (c->buffer, c->font);