[array] Don't clear serializer buffer when copying out
Not needed.
This commit is contained in:
parent
57808609c9
commit
3b68c7146f
|
@ -272,7 +272,7 @@ struct hb_array_t : hb_iter_with_fallback_t<hb_array_t<Type>, Type&>
|
||||||
{
|
{
|
||||||
TRACE_SERIALIZE (this);
|
TRACE_SERIALIZE (this);
|
||||||
auto* out = c->start_embed (arrayZ);
|
auto* out = c->start_embed (arrayZ);
|
||||||
if (unlikely (!c->extend_size (out, get_size ()))) return_trace (hb_array_t ());
|
if (unlikely (!c->extend_size (out, get_size (), false))) return_trace (hb_array_t ());
|
||||||
for (unsigned i = 0; i < length; i++)
|
for (unsigned i = 0; i < length; i++)
|
||||||
out[i] = arrayZ[i]; /* TODO: add version that calls c->copy() */
|
out[i] = arrayZ[i]; /* TODO: add version that calls c->copy() */
|
||||||
return_trace (hb_array_t (out, length));
|
return_trace (hb_array_t (out, length));
|
||||||
|
@ -285,7 +285,7 @@ struct hb_array_t : hb_iter_with_fallback_t<hb_array_t<Type>, Type&>
|
||||||
{
|
{
|
||||||
TRACE_SERIALIZE (this);
|
TRACE_SERIALIZE (this);
|
||||||
auto* out = c->start_embed (arrayZ);
|
auto* out = c->start_embed (arrayZ);
|
||||||
if (unlikely (!c->extend_size (out, get_size ()))) return_trace (hb_array_t ());
|
if (unlikely (!c->extend_size (out, get_size (), false))) return_trace (hb_array_t ());
|
||||||
hb_memcpy (out, arrayZ, length);
|
hb_memcpy (out, arrayZ, length);
|
||||||
return_trace (hb_array_t (out, length));
|
return_trace (hb_array_t (out, length));
|
||||||
}
|
}
|
||||||
|
|
|
@ -571,7 +571,7 @@ struct hb_serialize_context_t
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Type>
|
template <typename Type>
|
||||||
Type *allocate_size (size_t size)
|
Type *allocate_size (size_t size, bool clear = true)
|
||||||
{
|
{
|
||||||
if (unlikely (in_error ())) return nullptr;
|
if (unlikely (in_error ())) return nullptr;
|
||||||
|
|
||||||
|
@ -580,7 +580,8 @@ struct hb_serialize_context_t
|
||||||
err (HB_SERIALIZE_ERROR_OUT_OF_ROOM);
|
err (HB_SERIALIZE_ERROR_OUT_OF_ROOM);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
hb_memset (this->head, 0, size);
|
if (clear)
|
||||||
|
hb_memset (this->head, 0, size);
|
||||||
char *ret = this->head;
|
char *ret = this->head;
|
||||||
this->head += size;
|
this->head += size;
|
||||||
return reinterpret_cast<Type *> (ret);
|
return reinterpret_cast<Type *> (ret);
|
||||||
|
@ -635,7 +636,7 @@ struct hb_serialize_context_t
|
||||||
hb_serialize_context_t& operator << (const Type &obj) & { embed (obj); return *this; }
|
hb_serialize_context_t& operator << (const Type &obj) & { embed (obj); return *this; }
|
||||||
|
|
||||||
template <typename Type>
|
template <typename Type>
|
||||||
Type *extend_size (Type *obj, size_t size)
|
Type *extend_size (Type *obj, size_t size, bool clear = true)
|
||||||
{
|
{
|
||||||
if (unlikely (in_error ())) return nullptr;
|
if (unlikely (in_error ())) return nullptr;
|
||||||
|
|
||||||
|
@ -643,12 +644,12 @@ struct hb_serialize_context_t
|
||||||
assert ((char *) obj <= this->head);
|
assert ((char *) obj <= this->head);
|
||||||
assert ((size_t) (this->head - (char *) obj) <= size);
|
assert ((size_t) (this->head - (char *) obj) <= size);
|
||||||
if (unlikely (((char *) obj + size < (char *) obj) ||
|
if (unlikely (((char *) obj + size < (char *) obj) ||
|
||||||
!this->allocate_size<Type> (((char *) obj) + size - this->head))) return nullptr;
|
!this->allocate_size<Type> (((char *) obj) + size - this->head, clear))) return nullptr;
|
||||||
return reinterpret_cast<Type *> (obj);
|
return reinterpret_cast<Type *> (obj);
|
||||||
}
|
}
|
||||||
template <typename Type>
|
template <typename Type>
|
||||||
Type *extend_size (Type &obj, size_t size)
|
Type *extend_size (Type &obj, size_t size, bool clear = true)
|
||||||
{ return extend_size (std::addressof (obj), size); }
|
{ return extend_size (std::addressof (obj), size, clear); }
|
||||||
|
|
||||||
template <typename Type>
|
template <typename Type>
|
||||||
Type *extend_min (Type *obj) { return extend_size (obj, obj->min_size); }
|
Type *extend_min (Type *obj) { return extend_size (obj, obj->min_size); }
|
||||||
|
|
Loading…
Reference in New Issue