[subset-cff] Pre-alloc enough for check-less copy
This commit is contained in:
parent
062e59ae67
commit
c755b3884f
|
@ -111,14 +111,9 @@ struct str_encoder_t
|
||||||
|
|
||||||
void copy_str (const unsigned char *str, unsigned length)
|
void copy_str (const unsigned char *str, unsigned length)
|
||||||
{
|
{
|
||||||
unsigned int offset = buff.length;
|
assert ((signed) (buff.length + length) <= buff.allocated);
|
||||||
/* Manually resize buffer since faster. */
|
hb_memcpy (buff.arrayZ + buff.length, str, length);
|
||||||
if (likely ((signed) (buff.length + length) <= buff.allocated))
|
|
||||||
buff.length += length;
|
buff.length += length;
|
||||||
else if (unlikely (!buff.resize (offset + length)))
|
|
||||||
return;
|
|
||||||
|
|
||||||
hb_memcpy (buff.arrayZ + offset, str, length);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool in_error () const { return buff.in_error (); }
|
bool in_error () const { return buff.in_error (); }
|
||||||
|
@ -986,8 +981,13 @@ struct subr_subsetter_t
|
||||||
|
|
||||||
unsigned size = 0;
|
unsigned size = 0;
|
||||||
for (unsigned int i = 0; i < count; i++)
|
for (unsigned int i = 0; i < count; i++)
|
||||||
|
{
|
||||||
size += arr[i].length;
|
size += arr[i].length;
|
||||||
buff.alloc (size);
|
if (arr[i].op == OpCode_callsubr || arr[i].op == OpCode_callgsubr)
|
||||||
|
size += 3;
|
||||||
|
}
|
||||||
|
if (!buff.alloc (size))
|
||||||
|
return false;
|
||||||
|
|
||||||
for (unsigned int i = 0; i < count; i++)
|
for (unsigned int i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue