[open-type] Add faster range-based loop to array types

This commit is contained in:
Behdad Esfahbod 2022-11-29 15:33:07 -07:00
parent dc82334061
commit 7129b79406
2 changed files with 13 additions and 1 deletions

View File

@ -646,6 +646,10 @@ struct ArrayOf
operator iter_t () const { return iter (); }
operator writer_t () { return writer (); }
/* Faster range-based for loop. */
const Type *begin () const { return arrayZ; }
const Type *end () const { return arrayZ + len; }
template <typename T>
Type &lsearch (const T &x, Type &not_found = Crap (Type))
{ return *as_array ().lsearch (x, &not_found); }
@ -819,6 +823,10 @@ struct HeadlessArrayOf
operator iter_t () const { return iter (); }
operator writer_t () { return writer (); }
/* Faster range-based for loop. */
const Type *begin () const { return arrayZ; }
const Type *end () const { return arrayZ + get_length (); }
bool serialize (hb_serialize_context_t *c, unsigned int items_len)
{
TRACE_SERIALIZE (this);
@ -935,6 +943,10 @@ struct SortedArrayOf : ArrayOf<Type, LenType>
operator iter_t () const { return iter (); }
operator writer_t () { return writer (); }
/* Faster range-based for loop. */
const Type *begin () const { return this->arrayZ; }
const Type *end () const { return this->arrayZ + this->len; }
bool serialize (hb_serialize_context_t *c, unsigned int items_len)
{
TRACE_SERIALIZE (this);

View File

@ -172,7 +172,7 @@ struct hb_vector_t
operator iter_t () const { return iter (); }
operator writer_t () { return writer (); }
/* Faster range-based for loop without constructing an hb_array_t. */
/* Faster range-based for loop. */
Type *begin () const { return arrayZ; }
Type *end () const { return arrayZ + length; }