[set] Add add_array()

To be used to optimize adding a whole bunch of (sorted) items at the same time,
as in CoverageFormat1.
pull/656/head
Behdad Esfahbod 7 years ago
parent 20e69c950d
commit 0fe62c1f33
  1. 4
      src/hb-ot-layout-common-private.hh
  2. 12
      src/hb-set-digest-private.hh
  3. 6
      src/hb-set-private.hh

@ -716,9 +716,7 @@ struct CoverageFormat1
template <typename set_t>
inline void add_coverage (set_t *glyphs) const {
unsigned int count = glyphArray.len;
for (unsigned int i = 0; i < count; i++)
glyphs->add (glyphArray[i]);
glyphs->add_array (glyphArray.array, glyphArray.len);
}
public:

@ -80,6 +80,12 @@ struct hb_set_digest_lowest_bits_t
mask |= mb + (mb - ma) - (mb < ma);
}
}
template <typename T>
inline void add_array (const T *array, unsigned int count)
{
for (unsigned int i = 0; i < count; i++)
add (array[i]);
}
inline bool may_have (hb_codepoint_t g) const {
return !!(mask & mask_for (g));
@ -112,6 +118,12 @@ struct hb_set_digest_combiner_t
head.add_range (a, b);
tail.add_range (a, b);
}
template <typename T>
inline void add_array (const T *array, unsigned int count)
{
head.add_array (array, count);
tail.add_array (array, count);
}
inline bool may_have (hb_codepoint_t g) const {
return head.may_have (g) && tail.may_have (g);

@ -248,6 +248,12 @@ struct hb_set_t
page->add_range (major_start (mb), b);
}
}
template <typename T>
inline void add_array (const T *array, unsigned int count)
{
for (unsigned int i = 0; i < count; i++)
add (array[i]);
}
inline void del (hb_codepoint_t g)
{
if (unlikely (in_error)) return;

Loading…
Cancel
Save