[ClassDef] Add ability to use a cache

pull/5043/head
Behdad Esfahbod 1 week ago
parent 7392f32e47
commit 3f40edbfa0
  1. 13
      src/hb-ot-layout-common.hh

@ -34,6 +34,7 @@
#include "hb-open-type.hh"
#include "hb-set.hh"
#include "hb-bimap.hh"
#include "hb-cache.hh"
#include "OT/Layout/Common/Coverage.hh"
#include "OT/Layout/types.hh"
@ -47,6 +48,9 @@ using OT::Layout::MediumTypes;
namespace OT {
using hb_ot_class_cache_t = hb_cache_t<15, 8, 7>;
static_assert (sizeof (hb_ot_class_cache_t) == 256, "");
template<typename Iterator>
static inline bool ClassDef_serialize (hb_serialize_context_t *c,
Iterator it);
@ -2076,6 +2080,15 @@ struct ClassDef
default:return 0;
}
}
unsigned int get_class (hb_codepoint_t glyph_id,
hb_ot_class_cache_t *cache) const
{
unsigned klass;
if (cache && cache->get (glyph_id, &klass)) return klass;
klass = get_class (glyph_id);
if (cache) cache->set (glyph_id, klass);
return klass;
}
unsigned get_population () const
{

Loading…
Cancel
Save