diff --git a/src/hb-open-file-private.hh b/src/hb-open-file-private.hh index 6d17db792..c56ce8f0d 100644 --- a/src/hb-open-file-private.hh +++ b/src/hb-open-file-private.hh @@ -168,7 +168,7 @@ struct TTCHeader inline bool sanitize (hb_sanitize_context_t *context) { TRACE_SANITIZE (); - if (!u.header.version.sanitize (context)) return false; + if (unlikely (!u.header.version.sanitize (context))) return false; switch (u.header.version) { case 2: /* version 2 is compatible with version 1 */ case 1: return u.version1.sanitize (context); @@ -230,7 +230,7 @@ struct OpenTypeFontFile inline bool sanitize (hb_sanitize_context_t *context) { TRACE_SANITIZE (); - if (!u.tag.sanitize (context)) return false; + if (unlikely (!u.tag.sanitize (context))) return false; switch (u.tag) { case CFFTag: /* All the non-collection tags */ case TrueTag: diff --git a/src/hb-open-type-private.hh b/src/hb-open-type-private.hh index 5afccbf08..52afd6b39 100644 --- a/src/hb-open-type-private.hh +++ b/src/hb-open-type-private.hh @@ -386,7 +386,7 @@ struct IntType inline bool operator != (const IntType &o) const { return v != o.v; } inline bool sanitize (hb_sanitize_context_t *context) { TRACE_SANITIZE (); - return context->check_struct (this); + return likely (context->check_struct (this)); } protected: BEInt v; @@ -482,7 +482,7 @@ struct GenericOffsetTo : OffsetType inline bool sanitize (hb_sanitize_context_t *context, void *base) { TRACE_SANITIZE (); - if (!context->check_struct (this)) return false; + if (unlikely (!context->check_struct (this))) return false; unsigned int offset = *this; if (unlikely (!offset)) return true; Type &obj = StructAtOffset (base, offset); @@ -491,7 +491,7 @@ struct GenericOffsetTo : OffsetType template inline bool sanitize (hb_sanitize_context_t *context, void *base, T user_data) { TRACE_SANITIZE (); - if (!context->check_struct (this)) return false; + if (unlikely (!context->check_struct (this))) return false; unsigned int offset = *this; if (unlikely (!offset)) return true; Type &obj = StructAtOffset (base, offset); @@ -547,7 +547,7 @@ struct GenericArrayOf inline bool sanitize (hb_sanitize_context_t *context) { TRACE_SANITIZE (); - if (!likely (sanitize_shallow (context))) return false; + if (unlikely (!sanitize_shallow (context))) return false; /* Note: for structs that do not reference other structs, * we do not need to call their sanitize() as we already did * a bound check on the aggregate array size, hence the return. @@ -564,20 +564,20 @@ struct GenericArrayOf } inline bool sanitize (hb_sanitize_context_t *context, void *base) { TRACE_SANITIZE (); - if (!likely (sanitize_shallow (context))) return false; + if (unlikely (!sanitize_shallow (context))) return false; unsigned int count = len; for (unsigned int i = 0; i < count; i++) - if (!array[i].sanitize (context, base)) + if (unlikely (!array[i].sanitize (context, base))) return false; return true; } template inline bool sanitize (hb_sanitize_context_t *context, void *base, T user_data) { TRACE_SANITIZE (); - if (!likely (sanitize_shallow (context))) return false; + if (unlikely (!sanitize_shallow (context))) return false; unsigned int count = len; for (unsigned int i = 0; i < count; i++) - if (!array[i].sanitize (context, base, user_data)) + if (unlikely (!array[i].sanitize (context, base, user_data))) return false; return true; } @@ -658,7 +658,7 @@ struct HeadlessArrayOf inline bool sanitize (hb_sanitize_context_t *context) { TRACE_SANITIZE (); - if (!likely (sanitize_shallow (context))) return false; + if (unlikely (!sanitize_shallow (context))) return false; /* Note: for structs that do not reference other structs, * we do not need to call their sanitize() as we already did * a bound check on the aggregate array size, hence the return. @@ -670,7 +670,7 @@ struct HeadlessArrayOf unsigned int count = len ? len - 1 : 0; Type *a = array; for (unsigned int i = 0; i < count; i++) - if (!a[i].sanitize (context)) + if (unlikely (!a[i].sanitize (context))) return false; return true; }