From dff1b809a0535d3c32cf7e8f10cbd5fb8926bca9 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Wed, 16 Nov 2022 16:19:05 -0700 Subject: [PATCH] [buffer] Add .digest() and use --- src/hb-buffer.hh | 9 +++++++++ src/hb-ot-layout.cc | 11 ++--------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/hb-buffer.hh b/src/hb-buffer.hh index 26c3f0fac..655503c46 100644 --- a/src/hb-buffer.hh +++ b/src/hb-buffer.hh @@ -32,6 +32,7 @@ #include "hb.hh" #include "hb-unicode.hh" +#include "hb-set-digest.hh" #ifndef HB_BUFFER_MAX_LEN_FACTOR @@ -207,6 +208,14 @@ struct hb_buffer_t hb_glyph_info_t &prev () { return out_info[out_len ? out_len - 1 : 0]; } hb_glyph_info_t prev () const { return out_info[out_len ? out_len - 1 : 0]; } + hb_set_digest_t digest () const + { + hb_set_digest_t d; + d.init (); + d.add_array (&info[0].codepoint, len, sizeof (info[0])); + return d; + } + HB_INTERNAL void similar (const hb_buffer_t &src); HB_INTERNAL void reset (); HB_INTERNAL void clear (); diff --git a/src/hb-ot-layout.cc b/src/hb-ot-layout.cc index 239759308..bc1e498dd 100644 --- a/src/hb-ot-layout.cc +++ b/src/hb-ot-layout.cc @@ -1955,11 +1955,7 @@ 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::template dispatch_recurse_func); - hb_set_digest_t digest; - digest.init (); - digest.add_array (&buffer->info[0].codepoint, - buffer->len, - sizeof (buffer->info[0])); + hb_set_digest_t digest = buffer->digest (); for (unsigned int stage_index = 0; stage_index < stages[table_index].length; stage_index++) { @@ -1983,10 +1979,7 @@ inline void hb_ot_map_t::apply (const Proxy &proxy, proxy.accels[lookup_index]) && table_index == 0) { - digest.init (); - digest.add_array (&buffer->info[0].codepoint, - buffer->len, - sizeof (buffer->info[0])); + digest = buffer->digest (); } }