[sanitize] Simplify

This commit is contained in:
Behdad Esfahbod 2019-05-10 22:23:24 -07:00
parent 23168c3981
commit 4dcf65328f
1 changed files with 10 additions and 35 deletions

View File

@ -440,21 +440,12 @@ struct UnsizedArrayOf
return_trace (out);
}
bool sanitize (hb_sanitize_context_t *c, unsigned int count) const
{
TRACE_SANITIZE (this);
if (unlikely (!sanitize_shallow (c, count))) return_trace (false);
static_assert ((hb_void_t<decltype (hb_declval (Type).sanitize (c))> (), true), "");
static_assert (hb_is_trivially_copyable (Type), "");
return_trace (true);
}
template <typename ...Ts>
bool sanitize (hb_sanitize_context_t *c, unsigned int count, Ts&&... ds) const
{
TRACE_SANITIZE (this);
if (unlikely (!sanitize_shallow (c, count))) return_trace (false);
if (hb_is_trivially_copyable (Type)) return_trace (true);
for (unsigned int i = 0; i < count; i++)
if (unlikely (!c->dispatch (arrayZ[i], hb_forward<Ts> (ds)...)))
return_trace (false);
@ -609,21 +600,12 @@ struct ArrayOf
return_trace (out);
}
bool sanitize (hb_sanitize_context_t *c) const
{
TRACE_SANITIZE (this);
if (unlikely (!sanitize_shallow (c))) return_trace (false);
static_assert ((hb_void_t<decltype (hb_declval (Type).sanitize (c))> (), true), "");
static_assert (hb_is_trivially_copyable (Type), "");
return_trace (true);
}
template <typename ...Ts>
bool sanitize (hb_sanitize_context_t *c, Ts&&... ds) const
{
TRACE_SANITIZE (this);
if (unlikely (!sanitize_shallow (c))) return_trace (false);
if (hb_is_trivially_copyable (Type)) return_trace (true);
unsigned int count = len;
for (unsigned int i = 0; i < count; i++)
if (unlikely (!c->dispatch (arrayZ[i], hb_forward<Ts> (ds)...)))
@ -736,14 +718,16 @@ struct HeadlessArrayOf
return_trace (true);
}
bool sanitize (hb_sanitize_context_t *c) const
template <typename ...Ts>
bool sanitize (hb_sanitize_context_t *c, Ts&&... ds) const
{
TRACE_SANITIZE (this);
if (unlikely (!sanitize_shallow (c))) return_trace (false);
static_assert ((hb_void_t<decltype (hb_declval (Type).sanitize (c))> (), true), "");
static_assert (hb_is_trivially_copyable (Type), "");
if (hb_is_trivially_copyable (Type)) return_trace (true);
unsigned int count = lenP1 ? lenP1 - 1 : 0;
for (unsigned int i = 0; i < count; i++)
if (unlikely (!c->dispatch (arrayZ[i], hb_forward<Ts> (ds)...)))
return_trace (false);
return_trace (true);
}
@ -965,21 +949,12 @@ struct VarSizedBinSearchArrayOf
unsigned int get_size () const
{ return header.static_size + header.nUnits * header.unitSize; }
bool sanitize (hb_sanitize_context_t *c) const
{
TRACE_SANITIZE (this);
if (unlikely (!sanitize_shallow (c))) return_trace (false);
static_assert ((hb_void_t<decltype (hb_declval (Type).sanitize (c))> (), true), "");
static_assert (hb_is_trivially_copyable (Type), "");
return_trace (true);
}
template <typename ...Ts>
bool sanitize (hb_sanitize_context_t *c, Ts&&... ds) const
{
TRACE_SANITIZE (this);
if (unlikely (!sanitize_shallow (c))) return_trace (false);
if (hb_is_trivially_copyable (Type)) return_trace (true);
unsigned int count = get_length ();
for (unsigned int i = 0; i < count; i++)
if (unlikely (!(*this)[i].sanitize (c, hb_forward<Ts> (ds)...)))