[cff] Allocate stack inline instead of using hb_vector_t
Speeds up glyph_extents and glyph_shape benchmarks for CFF by 10
to 16 percent!
diff --git a/src/hb-cff-interp-common.hh b/src/hb-cff-interp-common.hh
index ab622a7..0b5ee3c 100644
--- a/src/hb-cff-interp-common.hh
+++ b/src/hb-cff-interp-common.hh
@@ -355,10 +355,8 @@
{
error = false;
count = 0;
- elements.init ();
- elements.resize (kSizeLimit);
}
- void fini () { elements.fini (); }
+ void fini () {}
ELEM& operator [] (unsigned int i)
{
@@ -368,14 +366,14 @@
void push (const ELEM &v)
{
- if (likely (count < elements.length))
+ if (likely (count < LIMIT))
elements[count++] = v;
else
set_error ();
}
ELEM &push ()
{
- if (likely (count < elements.length))
+ if (likely (count < LIMIT))
return elements[count++];
else
{
@@ -414,7 +412,7 @@
void unpop ()
{
- if (likely (count < elements.length))
+ if (likely (count < LIMIT))
count++;
else
set_error ();
@@ -422,18 +420,16 @@
void clear () { count = 0; }
- bool in_error () const { return (error || elements.in_error ()); }
+ bool in_error () const { return (error); }
void set_error () { error = true; }
unsigned int get_count () const { return count; }
bool is_empty () const { return !count; }
- static constexpr unsigned kSizeLimit = LIMIT;
-
protected:
bool error;
unsigned int count;
- hb_vector_t<ELEM> elements;
+ ELEM elements[LIMIT];
};
/* argument stack */
@@ -489,7 +485,7 @@
}
hb_array_t<const ARG> get_subarray (unsigned int start) const
- { return S::elements.sub_array (start); }
+ { return hb_array_t<const ARG> (S::elements).sub_array (start); }
private:
typedef cff_stack_t<ARG, 513> S;