[buffer] Add .digest() and use

This commit is contained in:
Behdad Esfahbod 2022-11-16 16:19:05 -07:00
parent 654a2eafc8
commit dff1b809a0
2 changed files with 11 additions and 9 deletions

View File

@ -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 ();

View File

@ -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<OT::hb_ot_apply_context_t>);
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 ();
}
}