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