[sanitize] Use hb_is_trivially_copyable()

This commit is contained in:
Behdad Esfahbod 2019-05-10 22:11:51 -07:00
parent 0ff7954f9f
commit 23168c3981
1 changed files with 8 additions and 56 deletions

View File

@ -445,20 +445,8 @@ struct UnsizedArrayOf
TRACE_SANITIZE (this); TRACE_SANITIZE (this);
if (unlikely (!sanitize_shallow (c, count))) return_trace (false); if (unlikely (!sanitize_shallow (c, count))) return_trace (false);
/* Note: for structs that do not reference other structs, static_assert ((hb_void_t<decltype (hb_declval (Type).sanitize (c))> (), true), "");
* we do not need to call their sanitize() as we already did static_assert (hb_is_trivially_copyable (Type), "");
* a bound check on the aggregate array size. We just include
* a small unreachable expression to make sure the structs
* pointed to do have a simple sanitize() as well as an
* assignment opreator. This ensures that they do not
* reference other structs via offsets.
*/
if (false)
{
arrayZ[0].sanitize (c);
Type v;
v = arrayZ[0];
}
return_trace (true); return_trace (true);
} }
@ -626,20 +614,8 @@ struct ArrayOf
TRACE_SANITIZE (this); TRACE_SANITIZE (this);
if (unlikely (!sanitize_shallow (c))) return_trace (false); if (unlikely (!sanitize_shallow (c))) return_trace (false);
/* Note: for structs that do not reference other structs, static_assert ((hb_void_t<decltype (hb_declval (Type).sanitize (c))> (), true), "");
* we do not need to call their sanitize() as we already did static_assert (hb_is_trivially_copyable (Type), "");
* a bound check on the aggregate array size. We just include
* a small unreachable expression to make sure the structs
* pointed to do have a simple sanitize() as well as an
* assignment opreator. This ensures that they do not
* reference other structs via offsets.
*/
if (false)
{
arrayZ[0].sanitize (c);
Type v;
v = arrayZ[0];
}
return_trace (true); return_trace (true);
} }
@ -765,20 +741,8 @@ struct HeadlessArrayOf
TRACE_SANITIZE (this); TRACE_SANITIZE (this);
if (unlikely (!sanitize_shallow (c))) return_trace (false); if (unlikely (!sanitize_shallow (c))) return_trace (false);
/* Note: for structs that do not reference other structs, static_assert ((hb_void_t<decltype (hb_declval (Type).sanitize (c))> (), true), "");
* we do not need to call their sanitize() as we already did static_assert (hb_is_trivially_copyable (Type), "");
* a bound check on the aggregate array size. We just include
* a small unreachable expression to make sure the structs
* pointed to do have a simple sanitize() as well as an
* assignment opreator. This ensures that they do not
* reference other structs via offsets.
*/
if (false)
{
arrayZ[0].sanitize (c);
Type v;
v = arrayZ[0];
}
return_trace (true); return_trace (true);
} }
@ -1006,20 +970,8 @@ struct VarSizedBinSearchArrayOf
TRACE_SANITIZE (this); TRACE_SANITIZE (this);
if (unlikely (!sanitize_shallow (c))) return_trace (false); if (unlikely (!sanitize_shallow (c))) return_trace (false);
/* Note: for structs that do not reference other structs, static_assert ((hb_void_t<decltype (hb_declval (Type).sanitize (c))> (), true), "");
* we do not need to call their sanitize() as we already did static_assert (hb_is_trivially_copyable (Type), "");
* a bound check on the aggregate array size. We just include
* a small unreachable expression to make sure the structs
* pointed to do have a simple sanitize() as well as an
* assignment opreator. This ensures that they do not
* reference other structs via offsets.
*/
if (false)
{
(*this)[0].sanitize (c);
Type v;
v = (*this)[0];
}
return_trace (true); return_trace (true);
} }