[array/vector] Rename len to length
diff --git a/src/hb-array.hh b/src/hb-array.hh
index a07560f..1d25860 100644
--- a/src/hb-array.hh
+++ b/src/hb-array.hh
@@ -45,9 +45,9 @@
/*
* Constructors.
*/
- hb_array_t () : arrayZ (nullptr), len (0) {}
- hb_array_t (Type *array_, unsigned int len_) : arrayZ (array_), len (len_) {}
- template <unsigned int len_> hb_array_t (Type (&array_)[len_]) : arrayZ (array_), len (len_) {}
+ hb_array_t () : arrayZ (nullptr), length (0) {}
+ hb_array_t (Type *array_, unsigned int length_) : arrayZ (array_), length (length_) {}
+ template <unsigned int length_> hb_array_t (Type (&array_)[length_]) : arrayZ (array_), length (length_) {}
/*
* Operators.
@@ -56,29 +56,29 @@
Type& operator [] (int i_) const
{
unsigned int i = (unsigned int) i_;
- if (unlikely (i >= len)) return CrapOrNull(Type);
+ if (unlikely (i >= length)) return CrapOrNull(Type);
return arrayZ[i];
}
- explicit_operator bool () const { return len; }
+ explicit_operator bool () const { return length; }
Type * operator & () const { return arrayZ; }
Type & operator * () { return (this->operator [])[0]; }
- operator hb_array_t<const Type> () { return hb_array_t<const Type> (arrayZ, len); }
+ operator hb_array_t<const Type> () { return hb_array_t<const Type> (arrayZ, length); }
template <typename T> operator T * () const { return arrayZ; }
hb_array_t<Type> & operator += (unsigned int count)
{
- if (unlikely (count > len))
- count = len;
- len -= count;
+ if (unlikely (count > length))
+ count = length;
+ length -= count;
arrayZ += count;
return *this;
}
hb_array_t<Type> & operator -= (unsigned int count)
{
- if (unlikely (count > len))
- count = len;
- len -= count;
+ if (unlikely (count > length))
+ count = length;
+ length -= count;
return *this;
}
hb_array_t<Type> & operator ++ () { *this += 1; }
@@ -99,8 +99,8 @@
/* Note: our compare is NOT lexicographic; it also does NOT call Type::cmp. */
int cmp (const hb_array_t<Type> &a) const
{
- if (len != a.len)
- return (int) a.len - (int) len;
+ if (length != a.length)
+ return (int) a.length - (int) length;
return hb_memcmp (a.arrayZ, arrayZ, get_size ());
}
static int cmp (const void *pa, const void *pb)
@@ -113,7 +113,7 @@
template <typename T>
Type *lsearch (const T &x, Type *not_found = nullptr)
{
- unsigned int count = len;
+ unsigned int count = length;
for (unsigned int i = 0; i < count; i++)
if (!this->arrayZ[i].cmp (x))
return &this->arrayZ[i];
@@ -122,7 +122,7 @@
template <typename T>
const Type *lsearch (const T &x, const Type *not_found = nullptr) const
{
- unsigned int count = len;
+ unsigned int count = length;
for (unsigned int i = 0; i < count; i++)
if (!this->arrayZ[i].cmp (x))
return &this->arrayZ[i];
@@ -131,17 +131,17 @@
hb_sorted_array_t<Type> qsort (int (*cmp_)(const void*, const void*))
{
- ::qsort (arrayZ, len, item_size, cmp_);
+ ::qsort (arrayZ, length, item_size, cmp_);
return hb_sorted_array_t<Type> (*this);
}
hb_sorted_array_t<Type> qsort ()
{
- ::qsort (arrayZ, len, item_size, Type::cmp);
+ ::qsort (arrayZ, length, item_size, Type::cmp);
return hb_sorted_array_t<Type> (*this);
}
void qsort (unsigned int start, unsigned int end)
{
- end = MIN (end, len);
+ end = MIN (end, length);
assert (start <= end);
::qsort (arrayZ + start, end - start, item_size, Type::cmp);
}
@@ -150,14 +150,14 @@
* Other methods.
*/
- unsigned int get_size () const { return len * item_size; }
+ unsigned int get_size () const { return length * item_size; }
hb_array_t<Type> sub_array (unsigned int start_offset = 0, unsigned int *seg_count = nullptr /* IN/OUT */) const
{
if (!start_offset && !seg_count)
return *this;
- unsigned int count = len;
+ unsigned int count = length;
if (unlikely (start_offset > count))
count = 0;
else
@@ -171,11 +171,11 @@
/* Only call if you allocated the underlying array using malloc() or similar. */
void free ()
- { ::free ((void *) arrayZ); arrayZ = nullptr; len = 0; }
+ { ::free ((void *) arrayZ); arrayZ = nullptr; length = 0; }
template <typename hb_sanitize_context_t>
bool sanitize (hb_sanitize_context_t *c) const
- { return c->check_array (arrayZ, len); }
+ { return c->check_array (arrayZ, length); }
/*
* Members
@@ -183,13 +183,13 @@
public:
Type *arrayZ;
- unsigned int len;
+ unsigned int length;
};
template <typename T> inline hb_array_t<T>
-hb_array (T *array, unsigned int len)
-{ return hb_array_t<T> (array, len); }
-template <typename T, unsigned int len_> inline hb_array_t<T>
-hb_array (T (&array_)[len_])
+hb_array (T *array, unsigned int length)
+{ return hb_array_t<T> (array, length); }
+template <typename T, unsigned int length_> inline hb_array_t<T>
+hb_array (T (&array_)[length_])
{ return hb_array_t<T> (array_); }
@@ -205,8 +205,8 @@
{
hb_sorted_array_t () : hb_array_t<Type> () {}
hb_sorted_array_t (const hb_array_t<Type> &o) : hb_array_t<Type> (o) {}
- hb_sorted_array_t (Type *array_, unsigned int len_) : hb_array_t<Type> (array_, len_) {}
- template <unsigned int len_> hb_sorted_array_t (Type (&array_)[len_]) : hb_array_t<Type> (array_) {}
+ hb_sorted_array_t (Type *array_, unsigned int length_) : hb_array_t<Type> (array_, length_) {}
+ template <unsigned int length_> hb_sorted_array_t (Type (&array_)[length_]) : hb_array_t<Type> (array_) {}
hb_sorted_array_t<Type> sub_array (unsigned int start_offset, unsigned int *seg_count /* IN/OUT */) const
{ return hb_sorted_array_t<Type> (((const hb_array_t<Type> *) (this))->sub_array (start_offset, seg_count)); }
@@ -230,7 +230,7 @@
hb_bfind_not_found_t not_found = HB_BFIND_NOT_FOUND_DONT_STORE,
unsigned int to_store = (unsigned int) -1) const
{
- int min = 0, max = (int) this->len - 1;
+ int min = 0, max = (int) this->length - 1;
const Type *array = this->arrayZ;
while (min <= max)
{
@@ -259,7 +259,7 @@
break;
case HB_BFIND_NOT_FOUND_STORE_CLOSEST:
- if (max < 0 || (max < (int) this->len && array[max].cmp (x) > 0))
+ if (max < 0 || (max < (int) this->length && array[max].cmp (x) > 0))
max++;
*i = max;
break;
@@ -269,10 +269,10 @@
}
};
template <typename T> inline hb_sorted_array_t<T>
-hb_sorted_array (T *array, unsigned int len)
-{ return hb_sorted_array_t<T> (array, len); }
-template <typename T, unsigned int len_> inline hb_sorted_array_t<T>
-hb_sorted_array (T (&array_)[len_])
+hb_sorted_array (T *array, unsigned int length)
+{ return hb_sorted_array_t<T> (array, length); }
+template <typename T, unsigned int length_> inline hb_sorted_array_t<T>
+hb_sorted_array (T (&array_)[length_])
{ return hb_sorted_array_t<T> (array_); }