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

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

No files matched your search

+12
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);
+1 -1
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; }