Cosmetic: Rename HB_LIKELY/HB_UNLIKELY to likely/unlikely

This commit is contained in:
Behdad Esfahbod 2010-05-03 22:51:19 -04:00
parent fa3b3d5844
commit 64d3fc8d0d
17 changed files with 147 additions and 147 deletions

View File

@ -258,7 +258,7 @@ hb_buffer_clear_positions (hb_buffer_t *buffer)
buffer->have_output = FALSE; buffer->have_output = FALSE;
buffer->have_positions = TRUE; buffer->have_positions = TRUE;
if (HB_UNLIKELY (!buffer->positions)) if (unlikely (!buffer->positions))
{ {
buffer->positions = calloc (buffer->allocated, sizeof (buffer->positions[0])); buffer->positions = calloc (buffer->allocated, sizeof (buffer->positions[0]));
return; return;
@ -510,7 +510,7 @@ reverse_range (hb_buffer_t *buffer,
void void
hb_buffer_reverse (hb_buffer_t *buffer) hb_buffer_reverse (hb_buffer_t *buffer)
{ {
if (HB_UNLIKELY (!buffer->in_length)) if (unlikely (!buffer->in_length))
return; return;
reverse_range (buffer, 0, buffer->in_length); reverse_range (buffer, 0, buffer->in_length);
@ -521,7 +521,7 @@ hb_buffer_reverse_clusters (hb_buffer_t *buffer)
{ {
unsigned int i, start, count, last_cluster; unsigned int i, start, count, last_cluster;
if (HB_UNLIKELY (!buffer->in_length)) if (unlikely (!buffer->in_length))
return; return;
hb_buffer_reverse (buffer); hb_buffer_reverse (buffer);
@ -569,7 +569,7 @@ hb_utf8_next (const uint8_t *text,
unsigned int mask, len; unsigned int mask, len;
UTF8_COMPUTE (c, mask, len); UTF8_COMPUTE (c, mask, len);
if (HB_UNLIKELY (!len || (unsigned int) (end - text) < len)) { if (unlikely (!len || (unsigned int) (end - text) < len)) {
*unicode = -1; *unicode = -1;
return text + 1; return text + 1;
} else { } else {
@ -578,7 +578,7 @@ hb_utf8_next (const uint8_t *text,
result = c & mask; result = c & mask;
for (i = 1; i < len; i++) for (i = 1; i < len; i++)
{ {
if (HB_UNLIKELY ((text[i] & 0xc0) != 0x80)) if (unlikely ((text[i] & 0xc0) != 0x80))
{ {
*unicode = -1; *unicode = -1;
return text + 1; return text + 1;
@ -610,10 +610,10 @@ hb_utf16_next (const uint16_t *text,
{ {
uint16_t c = *text++; uint16_t c = *text++;
if (HB_UNLIKELY (c >= 0xd800 && c < 0xdc00)) { if (unlikely (c >= 0xd800 && c < 0xdc00)) {
/* high surrogate */ /* high surrogate */
uint16_t l; uint16_t l;
if (text < end && ((l = *text), HB_UNLIKELY (l >= 0xdc00 && l < 0xe000))) { if (text < end && ((l = *text), unlikely (l >= 0xdc00 && l < 0xe000))) {
/* low surrogate */ /* low surrogate */
*unicode = ((hb_codepoint_t) ((c) - 0xd800) * 0x400 + (l) - 0xdc00 + 0x10000); *unicode = ((hb_codepoint_t) ((c) - 0xd800) * 0x400 + (l) - 0xdc00 + 0x10000);
text++; text++;

View File

@ -274,7 +274,7 @@ _hb_face_for_data_closure_create (hb_blob_t *blob, unsigned int index)
hb_face_for_data_closure_t *closure; hb_face_for_data_closure_t *closure;
closure = (hb_face_for_data_closure_t *) malloc (sizeof (hb_face_for_data_closure_t)); closure = (hb_face_for_data_closure_t *) malloc (sizeof (hb_face_for_data_closure_t));
if (HB_UNLIKELY (!closure)) if (unlikely (!closure))
return &_hb_face_for_data_closure_nil; return &_hb_face_for_data_closure_nil;
closure->blob = hb_blob_reference (blob); closure->blob = hb_blob_reference (blob);
@ -286,7 +286,7 @@ _hb_face_for_data_closure_create (hb_blob_t *blob, unsigned int index)
static void static void
_hb_face_for_data_closure_destroy (hb_face_for_data_closure_t *closure) _hb_face_for_data_closure_destroy (hb_face_for_data_closure_t *closure)
{ {
if (HB_LIKELY (closure != &_hb_face_for_data_closure_nil)) { if (likely (closure != &_hb_face_for_data_closure_nil)) {
hb_blob_destroy (closure->blob); hb_blob_destroy (closure->blob);
free (closure); free (closure);
} }
@ -361,7 +361,7 @@ hb_face_get_table (hb_face_t *face,
{ {
hb_blob_t *blob; hb_blob_t *blob;
if (HB_UNLIKELY (!face || !face->get_table)) if (unlikely (!face || !face->get_table))
return &_hb_blob_nil; return &_hb_blob_nil;
blob = face->get_table (tag, face->user_data); blob = face->get_table (tag, face->user_data);

View File

@ -43,7 +43,7 @@ hb_ft_get_glyph (hb_font_t *font HB_UNUSED,
FT_Face ft_face = (FT_Face) user_data; FT_Face ft_face = (FT_Face) user_data;
#ifdef HAVE_FT_FACE_GETCHARVARIANTINDEX #ifdef HAVE_FT_FACE_GETCHARVARIANTINDEX
if (HB_UNLIKELY (variation_selector)) { if (unlikely (variation_selector)) {
hb_codepoint_t glyph = FT_Face_GetCharVariantIndex (ft_face, unicode, variation_selector); hb_codepoint_t glyph = FT_Face_GetCharVariantIndex (ft_face, unicode, variation_selector);
if (glyph) if (glyph)
return glyph; return glyph;
@ -67,13 +67,13 @@ hb_ft_get_contour_point (hb_font_t *font HB_UNUSED,
/* TODO: load_flags, embolden, etc */ /* TODO: load_flags, embolden, etc */
if (HB_UNLIKELY (FT_Load_Glyph (ft_face, glyph, load_flags))) if (unlikely (FT_Load_Glyph (ft_face, glyph, load_flags)))
return FALSE; return FALSE;
if (HB_UNLIKELY (ft_face->glyph->format != FT_GLYPH_FORMAT_OUTLINE)) if (unlikely (ft_face->glyph->format != FT_GLYPH_FORMAT_OUTLINE))
return FALSE; return FALSE;
if (HB_UNLIKELY (point_index >= (unsigned int) ft_face->glyph->outline.n_points)) if (unlikely (point_index >= (unsigned int) ft_face->glyph->outline.n_points))
return FALSE; return FALSE;
*x = ft_face->glyph->outline.points[point_index].x; *x = ft_face->glyph->outline.points[point_index].x;
@ -97,7 +97,7 @@ hb_ft_get_glyph_metrics (hb_font_t *font HB_UNUSED,
metrics->x_advance = metrics->y_advance = 0; metrics->x_advance = metrics->y_advance = 0;
metrics->x_offset = metrics->y_offset = 0; metrics->x_offset = metrics->y_offset = 0;
metrics->width = metrics->height = 0; metrics->width = metrics->height = 0;
if (HB_LIKELY (!FT_Load_Glyph (ft_face, glyph, load_flags))) if (likely (!FT_Load_Glyph (ft_face, glyph, load_flags)))
{ {
/* TODO: A few negations should be in order here, not sure. */ /* TODO: A few negations should be in order here, not sure. */
metrics->x_advance = ft_face->glyph->advance.x; metrics->x_advance = ft_face->glyph->advance.x;
@ -152,7 +152,7 @@ _get_table (hb_tag_t tag, void *user_data)
FT_ULong length = 0; FT_ULong length = 0;
FT_Error error; FT_Error error;
if (HB_UNLIKELY (tag == HB_TAG_NONE)) if (unlikely (tag == HB_TAG_NONE))
return hb_blob_create_empty (); return hb_blob_create_empty ();
error = FT_Load_Sfnt_Table (ft_face, tag, 0, NULL, &length); error = FT_Load_Sfnt_Table (ft_face, tag, 0, NULL, &length);
@ -206,7 +206,7 @@ hb_ft_face_finalize (FT_Face ft_face)
hb_face_t * hb_face_t *
hb_ft_face_create_cached (FT_Face ft_face) hb_ft_face_create_cached (FT_Face ft_face)
{ {
if (HB_UNLIKELY (!ft_face->generic.data || ft_face->generic.finalizer != (FT_Generic_Finalizer) hb_ft_face_finalize)) if (unlikely (!ft_face->generic.data || ft_face->generic.finalizer != (FT_Generic_Finalizer) hb_ft_face_finalize))
{ {
if (ft_face->generic.finalizer) if (ft_face->generic.finalizer)
ft_face->generic.finalizer (ft_face); ft_face->generic.finalizer (ft_face);

View File

@ -89,7 +89,7 @@ hb_language_from_string (const char *str)
if (lang_equal (str, langs[i])) if (lang_equal (str, langs[i]))
return langs[i]; return langs[i];
if (HB_UNLIKELY (num_langs == num_alloced)) { if (unlikely (num_langs == num_alloced)) {
unsigned int new_alloced = 2 * (8 + num_alloced); unsigned int new_alloced = 2 * (8 + num_alloced);
const char **new_langs = realloc (langs, new_alloced * sizeof (langs[0])); const char **new_langs = realloc (langs, new_alloced * sizeof (langs[0]));
if (!new_langs) if (!new_langs)

View File

@ -82,7 +82,7 @@ _hb_object_debug_out (const void *obj,
/* Object allocation and lifecycle manamgement macros */ /* Object allocation and lifecycle manamgement macros */
#define HB_OBJECT_IS_INERT(obj) \ #define HB_OBJECT_IS_INERT(obj) \
(HB_UNLIKELY (HB_REFERENCE_COUNT_IS_INVALID ((obj)->ref_count))) (unlikely (HB_REFERENCE_COUNT_IS_INVALID ((obj)->ref_count)))
#define HB_OBJECT_DO_INIT_EXPR(obj) \ #define HB_OBJECT_DO_INIT_EXPR(obj) \
HB_REFERENCE_COUNT_INIT (obj->ref_count, 1) HB_REFERENCE_COUNT_INIT (obj->ref_count, 1)
@ -93,7 +93,7 @@ _hb_object_debug_out (const void *obj,
} HB_STMT_END } HB_STMT_END
#define HB_OBJECT_DO_CREATE(Type, obj) \ #define HB_OBJECT_DO_CREATE(Type, obj) \
HB_LIKELY (( \ likely (( \
(void) ( \ (void) ( \
((obj) = (Type *) calloc (1, sizeof (Type))) && \ ((obj) = (Type *) calloc (1, sizeof (Type))) && \
HB_OBJECT_DO_INIT_EXPR (obj) && \ HB_OBJECT_DO_INIT_EXPR (obj) && \
@ -105,7 +105,7 @@ _hb_object_debug_out (const void *obj,
#define HB_OBJECT_DO_REFERENCE(obj) \ #define HB_OBJECT_DO_REFERENCE(obj) \
HB_STMT_START { \ HB_STMT_START { \
int old_count; \ int old_count; \
if (HB_UNLIKELY (!(obj) || HB_OBJECT_IS_INERT (obj))) \ if (unlikely (!(obj) || HB_OBJECT_IS_INERT (obj))) \
return obj; \ return obj; \
HB_OBJECT_DEBUG_OUT (obj); \ HB_OBJECT_DEBUG_OUT (obj); \
old_count = hb_reference_count_inc (obj->ref_count); \ old_count = hb_reference_count_inc (obj->ref_count); \
@ -115,7 +115,7 @@ _hb_object_debug_out (const void *obj,
#define HB_OBJECT_DO_GET_REFERENCE_COUNT(obj) \ #define HB_OBJECT_DO_GET_REFERENCE_COUNT(obj) \
HB_STMT_START { \ HB_STMT_START { \
if (HB_UNLIKELY (!(obj) || HB_OBJECT_IS_INERT (obj))) \ if (unlikely (!(obj) || HB_OBJECT_IS_INERT (obj))) \
return 0; \ return 0; \
return HB_REFERENCE_COUNT_GET_VALUE (obj->ref_count); \ return HB_REFERENCE_COUNT_GET_VALUE (obj->ref_count); \
} HB_STMT_END } HB_STMT_END
@ -123,7 +123,7 @@ _hb_object_debug_out (const void *obj,
#define HB_OBJECT_DO_DESTROY(obj) \ #define HB_OBJECT_DO_DESTROY(obj) \
HB_STMT_START { \ HB_STMT_START { \
int old_count; \ int old_count; \
if (HB_UNLIKELY (!(obj) || HB_OBJECT_IS_INERT (obj))) \ if (unlikely (!(obj) || HB_OBJECT_IS_INERT (obj))) \
return; \ return; \
HB_OBJECT_DEBUG_OUT (obj); \ HB_OBJECT_DEBUG_OUT (obj); \
old_count = hb_reference_count_dec (obj->ref_count); \ old_count = hb_reference_count_dec (obj->ref_count); \

View File

@ -70,7 +70,7 @@ typedef struct OffsetTable
{ return numTables; } { return numTables; }
inline const TableDirectory& get_table (unsigned int i) const inline const TableDirectory& get_table (unsigned int i) const
{ {
if (HB_UNLIKELY (i >= numTables)) return Null(TableDirectory); if (unlikely (i >= numTables)) return Null(TableDirectory);
return tableDir[i]; return tableDir[i];
} }
inline bool find_table_index (hb_tag_t tag, unsigned int *table_index) const inline bool find_table_index (hb_tag_t tag, unsigned int *table_index) const

View File

@ -205,7 +205,7 @@ _hb_sanitize_array (SANITIZE_ARG_DEF,
context->start, context->end, context->start, context->end,
!overflows ? "does not overflow" : "OVERFLOWS FAIL"); !overflows ? "does not overflow" : "OVERFLOWS FAIL");
return HB_LIKELY (!overflows) && _hb_sanitize_check (SANITIZE_ARG, base, record_size * len); return likely (!overflows) && _hb_sanitize_check (SANITIZE_ARG, base, record_size * len);
} }
static inline bool static inline bool
@ -227,22 +227,22 @@ _hb_sanitize_edit (SANITIZE_ARG_DEF,
return context->writable; return context->writable;
} }
#define SANITIZE(X) HB_LIKELY ((X).sanitize (SANITIZE_ARG)) #define SANITIZE(X) likely ((X).sanitize (SANITIZE_ARG))
#define SANITIZE2(X,Y) (SANITIZE (X) && SANITIZE (Y)) #define SANITIZE2(X,Y) (SANITIZE (X) && SANITIZE (Y))
#define SANITIZE_THIS(X) HB_LIKELY ((X).sanitize (SANITIZE_ARG, CharP(this))) #define SANITIZE_THIS(X) likely ((X).sanitize (SANITIZE_ARG, CharP(this)))
#define SANITIZE_THIS2(X,Y) (SANITIZE_THIS (X) && SANITIZE_THIS (Y)) #define SANITIZE_THIS2(X,Y) (SANITIZE_THIS (X) && SANITIZE_THIS (Y))
#define SANITIZE_THIS3(X,Y,Z) (SANITIZE_THIS (X) && SANITIZE_THIS (Y) && SANITIZE_THIS(Z)) #define SANITIZE_THIS3(X,Y,Z) (SANITIZE_THIS (X) && SANITIZE_THIS (Y) && SANITIZE_THIS(Z))
#define SANITIZE_BASE(X,B) HB_LIKELY ((X).sanitize (SANITIZE_ARG, B)) #define SANITIZE_BASE(X,B) likely ((X).sanitize (SANITIZE_ARG, B))
#define SANITIZE_BASE2(X,Y,B) (SANITIZE_BASE (X,B) && SANITIZE_BASE (Y,B)) #define SANITIZE_BASE2(X,Y,B) (SANITIZE_BASE (X,B) && SANITIZE_BASE (Y,B))
#define SANITIZE_SELF() SANITIZE_OBJ (*this) #define SANITIZE_SELF() SANITIZE_OBJ (*this)
#define SANITIZE_OBJ(X) SANITIZE_MEM(&(X), sizeof (X)) #define SANITIZE_OBJ(X) SANITIZE_MEM(&(X), sizeof (X))
#define SANITIZE_MEM(B,L) HB_LIKELY (_hb_sanitize_check (SANITIZE_ARG, CharP(B), (L))) #define SANITIZE_MEM(B,L) likely (_hb_sanitize_check (SANITIZE_ARG, CharP(B), (L)))
#define SANITIZE_ARRAY(A,S,L) HB_LIKELY (_hb_sanitize_array (SANITIZE_ARG, CharP(A), S, L)) #define SANITIZE_ARRAY(A,S,L) likely (_hb_sanitize_array (SANITIZE_ARG, CharP(A), S, L))
#define NEUTER(Obj, Val) \ #define NEUTER(Obj, Val) \
(SANITIZE_OBJ (Obj) && \ (SANITIZE_OBJ (Obj) && \
@ -445,7 +445,7 @@ struct GenericOffsetTo : OffsetType
inline const Type& operator () (const void *base) const inline const Type& operator () (const void *base) const
{ {
unsigned int offset = *this; unsigned int offset = *this;
if (HB_UNLIKELY (!offset)) return Null(Type); if (unlikely (!offset)) return Null(Type);
return StructAtOffset<Type> (*CharP(base), offset); return StructAtOffset<Type> (*CharP(base), offset);
} }
@ -453,21 +453,21 @@ struct GenericOffsetTo : OffsetType
TRACE_SANITIZE (); TRACE_SANITIZE ();
if (!SANITIZE_SELF ()) return false; if (!SANITIZE_SELF ()) return false;
unsigned int offset = *this; unsigned int offset = *this;
if (HB_UNLIKELY (!offset)) return true; if (unlikely (!offset)) return true;
return SANITIZE (StructAtOffset<Type> (*CharP(base), offset)) || NEUTER (*this, 0); return SANITIZE (StructAtOffset<Type> (*CharP(base), offset)) || NEUTER (*this, 0);
} }
inline bool sanitize (SANITIZE_ARG_DEF, void *base, void *base2) { inline bool sanitize (SANITIZE_ARG_DEF, void *base, void *base2) {
TRACE_SANITIZE (); TRACE_SANITIZE ();
if (!SANITIZE_SELF ()) return false; if (!SANITIZE_SELF ()) return false;
unsigned int offset = *this; unsigned int offset = *this;
if (HB_UNLIKELY (!offset)) return true; if (unlikely (!offset)) return true;
return SANITIZE_BASE (StructAtOffset<Type> (*CharP(base), offset), base2) || NEUTER (*this, 0); return SANITIZE_BASE (StructAtOffset<Type> (*CharP(base), offset), base2) || NEUTER (*this, 0);
} }
inline bool sanitize (SANITIZE_ARG_DEF, void *base, unsigned int user_data) { inline bool sanitize (SANITIZE_ARG_DEF, void *base, unsigned int user_data) {
TRACE_SANITIZE (); TRACE_SANITIZE ();
if (!SANITIZE_SELF ()) return false; if (!SANITIZE_SELF ()) return false;
unsigned int offset = *this; unsigned int offset = *this;
if (HB_UNLIKELY (!offset)) return true; if (unlikely (!offset)) return true;
return SANITIZE_BASE (StructAtOffset<Type> (*CharP(base), offset), user_data) || NEUTER (*this, 0); return SANITIZE_BASE (StructAtOffset<Type> (*CharP(base), offset), user_data) || NEUTER (*this, 0);
} }
}; };
@ -494,7 +494,7 @@ struct GenericArrayOf
const Type *sub_array (unsigned int start_offset, unsigned int *pcount /* IN/OUT */) const const Type *sub_array (unsigned int start_offset, unsigned int *pcount /* IN/OUT */) const
{ {
unsigned int count = len; unsigned int count = len;
if (HB_UNLIKELY (start_offset > count)) if (unlikely (start_offset > count))
count = 0; count = 0;
else else
count -= start_offset; count -= start_offset;
@ -505,7 +505,7 @@ struct GenericArrayOf
inline const Type& operator [] (unsigned int i) const inline const Type& operator [] (unsigned int i) const
{ {
if (HB_UNLIKELY (i >= len)) return Null(Type); if (unlikely (i >= len)) return Null(Type);
return array()[i]; return array()[i];
} }
inline unsigned int get_size () const inline unsigned int get_size () const
@ -518,7 +518,7 @@ struct GenericArrayOf
inline bool sanitize (SANITIZE_ARG_DEF) { inline bool sanitize (SANITIZE_ARG_DEF) {
TRACE_SANITIZE (); TRACE_SANITIZE ();
if (!HB_LIKELY (sanitize_shallow (SANITIZE_ARG))) return false; if (!likely (sanitize_shallow (SANITIZE_ARG))) return false;
/* Note: for structs that do not reference other structs, /* Note: for structs that do not reference other structs,
* we do not need to call their sanitize() as we already did * we do not need to call their sanitize() as we already did
* a bound check on the aggregate array size, hence the return. * a bound check on the aggregate array size, hence the return.
@ -535,7 +535,7 @@ struct GenericArrayOf
} }
inline bool sanitize (SANITIZE_ARG_DEF, void *base) { inline bool sanitize (SANITIZE_ARG_DEF, void *base) {
TRACE_SANITIZE (); TRACE_SANITIZE ();
if (!HB_LIKELY (sanitize_shallow (SANITIZE_ARG))) return false; if (!likely (sanitize_shallow (SANITIZE_ARG))) return false;
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 (!array()[i].sanitize (SANITIZE_ARG, base)) if (!array()[i].sanitize (SANITIZE_ARG, base))
@ -544,7 +544,7 @@ struct GenericArrayOf
} }
inline bool sanitize (SANITIZE_ARG_DEF, void *base, void *base2) { inline bool sanitize (SANITIZE_ARG_DEF, void *base, void *base2) {
TRACE_SANITIZE (); TRACE_SANITIZE ();
if (!HB_LIKELY (sanitize_shallow (SANITIZE_ARG))) return false; if (!likely (sanitize_shallow (SANITIZE_ARG))) return false;
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 (!array()[i].sanitize (SANITIZE_ARG, base, base2)) if (!array()[i].sanitize (SANITIZE_ARG, base, base2))
@ -553,7 +553,7 @@ struct GenericArrayOf
} }
inline bool sanitize (SANITIZE_ARG_DEF, void *base, unsigned int user_data) { inline bool sanitize (SANITIZE_ARG_DEF, void *base, unsigned int user_data) {
TRACE_SANITIZE (); TRACE_SANITIZE ();
if (!HB_LIKELY (sanitize_shallow (SANITIZE_ARG))) return false; if (!likely (sanitize_shallow (SANITIZE_ARG))) return false;
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 (!array()[i].sanitize (SANITIZE_ARG, base, user_data)) if (!array()[i].sanitize (SANITIZE_ARG, base, user_data))
@ -591,7 +591,7 @@ struct OffsetListOf : OffsetArrayOf<Type>
{ {
inline const Type& operator [] (unsigned int i) const inline const Type& operator [] (unsigned int i) const
{ {
if (HB_UNLIKELY (i >= this->len)) return Null(Type); if (unlikely (i >= this->len)) return Null(Type);
return this+this->array()[i]; return this+this->array()[i];
} }
@ -616,7 +616,7 @@ struct HeadlessArrayOf
inline const Type& operator [] (unsigned int i) const inline const Type& operator [] (unsigned int i) const
{ {
if (HB_UNLIKELY (i >= len || !i)) return Null(Type); if (unlikely (i >= len || !i)) return Null(Type);
return array()[i-1]; return array()[i-1];
} }
inline unsigned int get_size () const inline unsigned int get_size () const
@ -629,7 +629,7 @@ struct HeadlessArrayOf
inline bool sanitize (SANITIZE_ARG_DEF) { inline bool sanitize (SANITIZE_ARG_DEF) {
TRACE_SANITIZE (); TRACE_SANITIZE ();
if (!HB_LIKELY (sanitize_shallow (SANITIZE_ARG))) return false; if (!likely (sanitize_shallow (SANITIZE_ARG))) return false;
/* Note: for structs that do not reference other structs, /* Note: for structs that do not reference other structs,
* we do not need to call their sanitize() as we already did * we do not need to call their sanitize() as we already did
* a bound check on the aggregate array size, hence the return. * a bound check on the aggregate array size, hence the return.

View File

@ -68,7 +68,7 @@ template <typename Type>
struct RecordArrayOf : ArrayOf<Record<Type> > { struct RecordArrayOf : ArrayOf<Record<Type> > {
inline const Tag& get_tag (unsigned int i) const inline const Tag& get_tag (unsigned int i) const
{ {
if (HB_UNLIKELY (i >= this->len)) return Null(Tag); if (unlikely (i >= this->len)) return Null(Tag);
return (*this)[i].tag; return (*this)[i].tag;
} }
inline unsigned int get_tags (unsigned int start_offset, inline unsigned int get_tags (unsigned int start_offset,
@ -120,7 +120,7 @@ struct IndexArray : ArrayOf<USHORT>
{ {
inline unsigned int operator [] (unsigned int i) const inline unsigned int operator [] (unsigned int i) const
{ {
if (HB_UNLIKELY (i >= this->len)) if (unlikely (i >= this->len))
return NO_INDEX; return NO_INDEX;
return this->array()[i]; return this->array()[i];
} }
@ -272,7 +272,7 @@ struct Lookup
inline unsigned int get_flag (void) const inline unsigned int get_flag (void) const
{ {
unsigned int flag = lookupFlag; unsigned int flag = lookupFlag;
if (HB_UNLIKELY (flag & LookupFlag::UseMarkFilteringSet)) if (unlikely (flag & LookupFlag::UseMarkFilteringSet))
{ {
const USHORT &markFilteringSet = StructAfter<USHORT> (subTable); const USHORT &markFilteringSet = StructAfter<USHORT> (subTable);
flag += (markFilteringSet << 16); flag += (markFilteringSet << 16);
@ -283,8 +283,8 @@ struct Lookup
inline bool sanitize (SANITIZE_ARG_DEF) { inline bool sanitize (SANITIZE_ARG_DEF) {
TRACE_SANITIZE (); TRACE_SANITIZE ();
/* Real sanitize of the subtables is done by GSUB/GPOS/... */ /* Real sanitize of the subtables is done by GSUB/GPOS/... */
if (!(SANITIZE_SELF () && HB_LIKELY (subTable.sanitize (SANITIZE_ARG)))) return false; if (!(SANITIZE_SELF () && likely (subTable.sanitize (SANITIZE_ARG)))) return false;
if (HB_UNLIKELY (lookupFlag & LookupFlag::UseMarkFilteringSet)) if (unlikely (lookupFlag & LookupFlag::UseMarkFilteringSet))
{ {
USHORT &markFilteringSet = StructAfter<USHORT> (subTable); USHORT &markFilteringSet = StructAfter<USHORT> (subTable);
if (!SANITIZE (markFilteringSet)) return false; if (!SANITIZE (markFilteringSet)) return false;
@ -317,7 +317,7 @@ struct CoverageFormat1
private: private:
inline unsigned int get_coverage (hb_codepoint_t glyph_id) const inline unsigned int get_coverage (hb_codepoint_t glyph_id) const
{ {
if (HB_UNLIKELY (glyph_id > 0xFFFF)) if (unlikely (glyph_id > 0xFFFF))
return NOT_COVERED; return NOT_COVERED;
GlyphID gid; GlyphID gid;
gid.set (glyph_id); gid.set (glyph_id);
@ -563,7 +563,7 @@ struct Device
inline int get_delta (unsigned int ppem_size) const inline int get_delta (unsigned int ppem_size) const
{ {
unsigned int f = deltaFormat; unsigned int f = deltaFormat;
if (HB_UNLIKELY (f < 1 || f > 3)) if (unlikely (f < 1 || f > 3))
return 0; return 0;
if (ppem_size < startSize || ppem_size > endSize) if (ppem_size < startSize || ppem_size > endSize)
@ -586,7 +586,7 @@ struct Device
inline unsigned int get_size () const inline unsigned int get_size () const
{ {
unsigned int f = deltaFormat; unsigned int f = deltaFormat;
if (HB_UNLIKELY (f < 1 || f > 3 || startSize > endSize)) return 3 * USHORT::get_size (); if (unlikely (f < 1 || f > 3 || startSize > endSize)) return 3 * USHORT::get_size ();
return USHORT::get_size () * (4 + ((endSize - startSize) >> (4 - f))); return USHORT::get_size () * (4 + ((endSize - startSize) >> (4 - f)));
} }

View File

@ -349,7 +349,7 @@ struct GDEF
inline bool sanitize (SANITIZE_ARG_DEF) { inline bool sanitize (SANITIZE_ARG_DEF) {
TRACE_SANITIZE (); TRACE_SANITIZE ();
if (!SANITIZE (version)) return false; if (!SANITIZE (version)) return false;
if (HB_UNLIKELY (version.major != 1)) return false; if (unlikely (version.major != 1)) return false;
return SANITIZE_THIS2 (glyphClassDef, attachList) && return SANITIZE_THIS2 (glyphClassDef, attachList) &&
SANITIZE_THIS2 (ligCaretList, markAttachClassDef) && SANITIZE_THIS2 (ligCaretList, markAttachClassDef) &&
(version < 0x00010002 || SANITIZE_THIS (markGlyphSetsDef[0])); (version < 0x00010002 || SANITIZE_THIS (markGlyphSetsDef[0]));

View File

@ -326,14 +326,14 @@ struct Anchor
struct AnchorMatrix struct AnchorMatrix
{ {
inline const Anchor& get_anchor (unsigned int row, unsigned int col, unsigned int cols) const { inline const Anchor& get_anchor (unsigned int row, unsigned int col, unsigned int cols) const {
if (HB_UNLIKELY (row >= rows || col >= cols)) return Null(Anchor); if (unlikely (row >= rows || col >= cols)) return Null(Anchor);
return this+matrix[row * cols + col]; return this+matrix[row * cols + col];
} }
inline bool sanitize (SANITIZE_ARG_DEF, unsigned int cols) { inline bool sanitize (SANITIZE_ARG_DEF, unsigned int cols) {
TRACE_SANITIZE (); TRACE_SANITIZE ();
if (!SANITIZE_SELF ()) return false; if (!SANITIZE_SELF ()) return false;
if (HB_UNLIKELY (cols >= ((unsigned int) -1) / rows)) return false; if (unlikely (cols >= ((unsigned int) -1) / rows)) return false;
unsigned int count = rows * cols; unsigned int count = rows * cols;
if (!SANITIZE_ARRAY (matrix, matrix[0].get_size (), count)) return false; if (!SANITIZE_ARRAY (matrix, matrix[0].get_size (), count)) return false;
for (unsigned int i = 0; i < count; i++) for (unsigned int i = 0; i < count; i++)
@ -422,7 +422,7 @@ struct SinglePosFormat1
{ {
TRACE_APPLY (); TRACE_APPLY ();
unsigned int index = (this+coverage) (IN_CURGLYPH ()); unsigned int index = (this+coverage) (IN_CURGLYPH ());
if (HB_LIKELY (index == NOT_COVERED)) if (likely (index == NOT_COVERED))
return false; return false;
valueFormat.apply_value (layout_context, CharP(this), values, CURPOSITION ()); valueFormat.apply_value (layout_context, CharP(this), values, CURPOSITION ());
@ -459,10 +459,10 @@ struct SinglePosFormat2
{ {
TRACE_APPLY (); TRACE_APPLY ();
unsigned int index = (this+coverage) (IN_CURGLYPH ()); unsigned int index = (this+coverage) (IN_CURGLYPH ());
if (HB_LIKELY (index == NOT_COVERED)) if (likely (index == NOT_COVERED))
return false; return false;
if (HB_LIKELY (index >= valueCount)) if (likely (index >= valueCount))
return false; return false;
valueFormat.apply_value (layout_context, CharP(this), valueFormat.apply_value (layout_context, CharP(this),
@ -568,17 +568,17 @@ struct PairPosFormat1
{ {
TRACE_APPLY (); TRACE_APPLY ();
unsigned int end = MIN (buffer->in_length, buffer->in_pos + context_length); unsigned int end = MIN (buffer->in_length, buffer->in_pos + context_length);
if (HB_UNLIKELY (buffer->in_pos + 2 > end)) if (unlikely (buffer->in_pos + 2 > end))
return false; return false;
unsigned int index = (this+coverage) (IN_CURGLYPH ()); unsigned int index = (this+coverage) (IN_CURGLYPH ());
if (HB_LIKELY (index == NOT_COVERED)) if (likely (index == NOT_COVERED))
return false; return false;
unsigned int j = buffer->in_pos + 1; unsigned int j = buffer->in_pos + 1;
while (_hb_ot_layout_skip_mark (layout_context->face, IN_INFO (j), context->lookup_flag, NULL)) while (_hb_ot_layout_skip_mark (layout_context->face, IN_INFO (j), context->lookup_flag, NULL))
{ {
if (HB_UNLIKELY (j == end)) if (unlikely (j == end))
return false; return false;
j++; j++;
} }
@ -614,7 +614,7 @@ struct PairPosFormat1
unsigned int len2 = valueFormat2.get_len (); unsigned int len2 = valueFormat2.get_len ();
if (!(SANITIZE_SELF () && SANITIZE_THIS (coverage) && if (!(SANITIZE_SELF () && SANITIZE_THIS (coverage) &&
HB_LIKELY (pairSet.sanitize (SANITIZE_ARG, CharP(this), len1 + len2)))) return false; likely (pairSet.sanitize (SANITIZE_ARG, CharP(this), len1 + len2)))) return false;
if (!(valueFormat1.has_device () || valueFormat2.has_device ())) return true; if (!(valueFormat1.has_device () || valueFormat2.has_device ())) return true;
@ -660,17 +660,17 @@ struct PairPosFormat2
{ {
TRACE_APPLY (); TRACE_APPLY ();
unsigned int end = MIN (buffer->in_length, buffer->in_pos + context_length); unsigned int end = MIN (buffer->in_length, buffer->in_pos + context_length);
if (HB_UNLIKELY (buffer->in_pos + 2 > end)) if (unlikely (buffer->in_pos + 2 > end))
return false; return false;
unsigned int index = (this+coverage) (IN_CURGLYPH ()); unsigned int index = (this+coverage) (IN_CURGLYPH ());
if (HB_LIKELY (index == NOT_COVERED)) if (likely (index == NOT_COVERED))
return false; return false;
unsigned int j = buffer->in_pos + 1; unsigned int j = buffer->in_pos + 1;
while (_hb_ot_layout_skip_mark (layout_context->face, IN_INFO (j), context->lookup_flag, NULL)) while (_hb_ot_layout_skip_mark (layout_context->face, IN_INFO (j), context->lookup_flag, NULL))
{ {
if (HB_UNLIKELY (j == end)) if (unlikely (j == end))
return false; return false;
j++; j++;
} }
@ -681,7 +681,7 @@ struct PairPosFormat2
unsigned int klass1 = (this+classDef1) (IN_CURGLYPH ()); unsigned int klass1 = (this+classDef1) (IN_CURGLYPH ());
unsigned int klass2 = (this+classDef2) (IN_GLYPH (j)); unsigned int klass2 = (this+classDef2) (IN_GLYPH (j));
if (HB_UNLIKELY (klass1 >= class1Count || klass2 >= class2Count)) if (unlikely (klass1 >= class1Count || klass2 >= class2Count))
return false; return false;
const Value *v = &values[record_len * (klass1 * class2Count + klass2)]; const Value *v = &values[record_len * (klass1 * class2Count + klass2)];
@ -927,7 +927,7 @@ struct CursivePosFormat1
return false; return false;
unsigned int index = (this+coverage) (IN_CURGLYPH ()); unsigned int index = (this+coverage) (IN_CURGLYPH ());
if (HB_LIKELY (index == NOT_COVERED)) if (likely (index == NOT_COVERED))
return false; return false;
const EntryExitRecord &record = entryExitRecord[index]; const EntryExitRecord &record = entryExitRecord[index];
@ -1034,7 +1034,7 @@ struct MarkBasePosFormat1
{ {
TRACE_APPLY (); TRACE_APPLY ();
unsigned int mark_index = (this+markCoverage) (IN_CURGLYPH ()); unsigned int mark_index = (this+markCoverage) (IN_CURGLYPH ());
if (HB_LIKELY (mark_index == NOT_COVERED)) if (likely (mark_index == NOT_COVERED))
return false; return false;
/* now we search backwards for a non-mark glyph */ /* now we search backwards for a non-mark glyph */
@ -1042,7 +1042,7 @@ struct MarkBasePosFormat1
unsigned int j = buffer->in_pos; unsigned int j = buffer->in_pos;
do do
{ {
if (HB_UNLIKELY (!j)) if (unlikely (!j))
return false; return false;
j--; j--;
} while (_hb_ot_layout_skip_mark (layout_context->face, IN_INFO (j), LookupFlag::IgnoreMarks, &property)); } while (_hb_ot_layout_skip_mark (layout_context->face, IN_INFO (j), LookupFlag::IgnoreMarks, &property));
@ -1063,7 +1063,7 @@ struct MarkBasePosFormat1
inline bool sanitize (SANITIZE_ARG_DEF) { inline bool sanitize (SANITIZE_ARG_DEF) {
TRACE_SANITIZE (); TRACE_SANITIZE ();
return SANITIZE_SELF () && SANITIZE_THIS3 (markCoverage, baseCoverage, markArray) && return SANITIZE_SELF () && SANITIZE_THIS3 (markCoverage, baseCoverage, markArray) &&
HB_LIKELY (baseArray.sanitize (SANITIZE_ARG, CharP(this), classCount)); likely (baseArray.sanitize (SANITIZE_ARG, CharP(this), classCount));
} }
private: private:
@ -1134,7 +1134,7 @@ struct MarkLigPosFormat1
{ {
TRACE_APPLY (); TRACE_APPLY ();
unsigned int mark_index = (this+markCoverage) (IN_CURGLYPH ()); unsigned int mark_index = (this+markCoverage) (IN_CURGLYPH ());
if (HB_LIKELY (mark_index == NOT_COVERED)) if (likely (mark_index == NOT_COVERED))
return false; return false;
/* now we search backwards for a non-mark glyph */ /* now we search backwards for a non-mark glyph */
@ -1142,7 +1142,7 @@ struct MarkLigPosFormat1
unsigned int j = buffer->in_pos; unsigned int j = buffer->in_pos;
do do
{ {
if (HB_UNLIKELY (!j)) if (unlikely (!j))
return false; return false;
j--; j--;
} while (_hb_ot_layout_skip_mark (layout_context->face, IN_INFO (j), LookupFlag::IgnoreMarks, &property)); } while (_hb_ot_layout_skip_mark (layout_context->face, IN_INFO (j), LookupFlag::IgnoreMarks, &property));
@ -1162,7 +1162,7 @@ struct MarkLigPosFormat1
/* Find component to attach to */ /* Find component to attach to */
unsigned int comp_count = lig_attach.rows; unsigned int comp_count = lig_attach.rows;
if (HB_UNLIKELY (!comp_count)) if (unlikely (!comp_count))
return false; return false;
unsigned int comp_index; unsigned int comp_index;
/* We must now check whether the ligature ID of the current mark glyph /* We must now check whether the ligature ID of the current mark glyph
@ -1184,7 +1184,7 @@ struct MarkLigPosFormat1
inline bool sanitize (SANITIZE_ARG_DEF) { inline bool sanitize (SANITIZE_ARG_DEF) {
TRACE_SANITIZE (); TRACE_SANITIZE ();
return SANITIZE_SELF () && SANITIZE_THIS3 (markCoverage, ligatureCoverage, markArray) && return SANITIZE_SELF () && SANITIZE_THIS3 (markCoverage, ligatureCoverage, markArray) &&
HB_LIKELY (ligatureArray.sanitize (SANITIZE_ARG, CharP(this), classCount)); likely (ligatureArray.sanitize (SANITIZE_ARG, CharP(this), classCount));
} }
private: private:
@ -1251,7 +1251,7 @@ struct MarkMarkPosFormat1
{ {
TRACE_APPLY (); TRACE_APPLY ();
unsigned int mark1_index = (this+mark1Coverage) (IN_CURGLYPH ()); unsigned int mark1_index = (this+mark1Coverage) (IN_CURGLYPH ());
if (HB_LIKELY (mark1_index == NOT_COVERED)) if (likely (mark1_index == NOT_COVERED))
return false; return false;
/* now we search backwards for a suitable mark glyph until a non-mark glyph */ /* now we search backwards for a suitable mark glyph until a non-mark glyph */
@ -1259,7 +1259,7 @@ struct MarkMarkPosFormat1
unsigned int j = buffer->in_pos; unsigned int j = buffer->in_pos;
do do
{ {
if (HB_UNLIKELY (!j)) if (unlikely (!j))
return false; return false;
j--; j--;
} while (_hb_ot_layout_skip_mark (layout_context->face, IN_INFO (j), context->lookup_flag, &property)); } while (_hb_ot_layout_skip_mark (layout_context->face, IN_INFO (j), context->lookup_flag, &property));
@ -1284,7 +1284,7 @@ struct MarkMarkPosFormat1
inline bool sanitize (SANITIZE_ARG_DEF) { inline bool sanitize (SANITIZE_ARG_DEF) {
TRACE_SANITIZE (); TRACE_SANITIZE ();
return SANITIZE_SELF () && SANITIZE_THIS3 (mark1Coverage, mark2Coverage, mark1Array) && return SANITIZE_SELF () && SANITIZE_THIS3 (mark1Coverage, mark2Coverage, mark1Array) &&
HB_LIKELY (mark2Array.sanitize (SANITIZE_ARG, CharP(this), classCount)); likely (mark2Array.sanitize (SANITIZE_ARG, CharP(this), classCount));
} }
private: private:
@ -1373,7 +1373,7 @@ struct ExtensionPos : Extension
inline const struct PosLookupSubTable& get_subtable (void) const inline const struct PosLookupSubTable& get_subtable (void) const
{ {
unsigned int offset = get_offset (); unsigned int offset = get_offset ();
if (HB_UNLIKELY (!offset)) return Null(PosLookupSubTable); if (unlikely (!offset)) return Null(PosLookupSubTable);
return StructAtOffset<PosLookupSubTable> (*this, offset); return StructAtOffset<PosLookupSubTable> (*this, offset);
} }
@ -1488,7 +1488,7 @@ struct PosLookup : Lookup
{ {
bool ret = false; bool ret = false;
if (HB_UNLIKELY (!buffer->in_length)) if (unlikely (!buffer->in_length))
return false; return false;
layout_context->info.gpos.last = HB_OT_LAYOUT_GPOS_NO_LAST; /* no last valid glyph for cursive pos. */ layout_context->info.gpos.last = HB_OT_LAYOUT_GPOS_NO_LAST; /* no last valid glyph for cursive pos. */
@ -1519,7 +1519,7 @@ struct PosLookup : Lookup
inline bool sanitize (SANITIZE_ARG_DEF) { inline bool sanitize (SANITIZE_ARG_DEF) {
TRACE_SANITIZE (); TRACE_SANITIZE ();
if (HB_UNLIKELY (!Lookup::sanitize (SANITIZE_ARG))) return false; if (unlikely (!Lookup::sanitize (SANITIZE_ARG))) return false;
OffsetArrayOf<PosLookupSubTable> &list = CastR<OffsetArrayOf<PosLookupSubTable> > (subTable); OffsetArrayOf<PosLookupSubTable> &list = CastR<OffsetArrayOf<PosLookupSubTable> > (subTable);
return SANITIZE_THIS (list); return SANITIZE_THIS (list);
} }
@ -1547,7 +1547,7 @@ struct GPOS : GSUBGPOS
inline bool sanitize (SANITIZE_ARG_DEF) { inline bool sanitize (SANITIZE_ARG_DEF) {
TRACE_SANITIZE (); TRACE_SANITIZE ();
if (HB_UNLIKELY (!GSUBGPOS::sanitize (SANITIZE_ARG))) return false; if (unlikely (!GSUBGPOS::sanitize (SANITIZE_ARG))) return false;
OffsetTo<PosLookupList> &list = CastR<OffsetTo<PosLookupList> > (lookupList); OffsetTo<PosLookupList> &list = CastR<OffsetTo<PosLookupList> > (lookupList);
return SANITIZE_THIS (list); return SANITIZE_THIS (list);
} }
@ -1566,9 +1566,9 @@ inline bool ExtensionPos::apply (APPLY_ARG_DEF) const
inline bool ExtensionPos::sanitize (SANITIZE_ARG_DEF) inline bool ExtensionPos::sanitize (SANITIZE_ARG_DEF)
{ {
TRACE_SANITIZE (); TRACE_SANITIZE ();
if (HB_UNLIKELY (!Extension::sanitize (SANITIZE_ARG))) return false; if (unlikely (!Extension::sanitize (SANITIZE_ARG))) return false;
unsigned int offset = get_offset (); unsigned int offset = get_offset ();
if (HB_UNLIKELY (!offset)) return true; if (unlikely (!offset)) return true;
return SANITIZE (StructAtOffset<PosLookupSubTable> (*this, offset)); return SANITIZE (StructAtOffset<PosLookupSubTable> (*this, offset));
} }
@ -1577,10 +1577,10 @@ static inline bool position_lookup (APPLY_ARG_DEF, unsigned int lookup_index)
const GPOS &gpos = *(layout_context->face->ot_layout.gpos); const GPOS &gpos = *(layout_context->face->ot_layout.gpos);
const PosLookup &l = gpos.get_lookup (lookup_index); const PosLookup &l = gpos.get_lookup (lookup_index);
if (HB_UNLIKELY (context->nesting_level_left == 0)) if (unlikely (context->nesting_level_left == 0))
return false; return false;
if (HB_UNLIKELY (context_length < 1)) if (unlikely (context_length < 1))
return false; return false;
return l.apply_once (layout_context, buffer, context_length, context->nesting_level_left - 1, apply_depth + 1); return l.apply_once (layout_context, buffer, context_length, context->nesting_level_left - 1, apply_depth + 1);

View File

@ -41,7 +41,7 @@ struct SingleSubstFormat1
TRACE_APPLY (); TRACE_APPLY ();
hb_codepoint_t glyph_id = IN_CURGLYPH (); hb_codepoint_t glyph_id = IN_CURGLYPH ();
unsigned int index = (this+coverage) (glyph_id); unsigned int index = (this+coverage) (glyph_id);
if (HB_LIKELY (index == NOT_COVERED)) if (likely (index == NOT_COVERED))
return false; return false;
glyph_id += deltaGlyphID; glyph_id += deltaGlyphID;
@ -80,10 +80,10 @@ struct SingleSubstFormat2
TRACE_APPLY (); TRACE_APPLY ();
hb_codepoint_t glyph_id = IN_CURGLYPH (); hb_codepoint_t glyph_id = IN_CURGLYPH ();
unsigned int index = (this+coverage) (glyph_id); unsigned int index = (this+coverage) (glyph_id);
if (HB_LIKELY (index == NOT_COVERED)) if (likely (index == NOT_COVERED))
return false; return false;
if (HB_UNLIKELY (index >= substitute.len)) if (unlikely (index >= substitute.len))
return false; return false;
glyph_id = substitute[index]; glyph_id = substitute[index];
@ -155,7 +155,7 @@ struct Sequence
inline bool apply (APPLY_ARG_DEF) const inline bool apply (APPLY_ARG_DEF) const
{ {
TRACE_APPLY (); TRACE_APPLY ();
if (HB_UNLIKELY (!substitute.len)) if (unlikely (!substitute.len))
return false; return false;
_hb_buffer_add_output_glyphs_be16 (buffer, 1, _hb_buffer_add_output_glyphs_be16 (buffer, 1,
@ -200,7 +200,7 @@ struct MultipleSubstFormat1
TRACE_APPLY (); TRACE_APPLY ();
unsigned int index = (this+coverage) (IN_CURGLYPH ()); unsigned int index = (this+coverage) (IN_CURGLYPH ());
if (HB_LIKELY (index == NOT_COVERED)) if (likely (index == NOT_COVERED))
return false; return false;
return (this+sequence[index]).apply (APPLY_ARG); return (this+sequence[index]).apply (APPLY_ARG);
@ -270,12 +270,12 @@ struct AlternateSubstFormat1
hb_codepoint_t glyph_id = IN_CURGLYPH (); hb_codepoint_t glyph_id = IN_CURGLYPH ();
unsigned int index = (this+coverage) (glyph_id); unsigned int index = (this+coverage) (glyph_id);
if (HB_LIKELY (index == NOT_COVERED)) if (likely (index == NOT_COVERED))
return false; return false;
const AlternateSet &alt_set = this+alternateSet[index]; const AlternateSet &alt_set = this+alternateSet[index];
if (HB_UNLIKELY (!alt_set.len)) if (unlikely (!alt_set.len))
return false; return false;
unsigned int alt_index = 0; unsigned int alt_index = 0;
@ -287,7 +287,7 @@ struct AlternateSubstFormat1
alt_set.len, alt_set.array); alt_set.len, alt_set.array);
*/ */
if (HB_UNLIKELY (alt_index >= alt_set.len)) if (unlikely (alt_index >= alt_set.len))
return false; return false;
glyph_id = alt_set[alt_index]; glyph_id = alt_set[alt_index];
@ -360,7 +360,7 @@ struct Ligature
unsigned int i, j; unsigned int i, j;
unsigned int count = component.len; unsigned int count = component.len;
unsigned int end = MIN (buffer->in_length, buffer->in_pos + context_length); unsigned int end = MIN (buffer->in_length, buffer->in_pos + context_length);
if (HB_UNLIKELY (buffer->in_pos + count > end)) if (unlikely (buffer->in_pos + count > end))
return false; return false;
for (i = 1, j = buffer->in_pos + 1; i < count; i++, j++) for (i = 1, j = buffer->in_pos + 1; i < count; i++, j++)
@ -368,7 +368,7 @@ struct Ligature
unsigned int property; unsigned int property;
while (_hb_ot_layout_skip_mark (layout_context->face, IN_INFO (j), context->lookup_flag, &property)) while (_hb_ot_layout_skip_mark (layout_context->face, IN_INFO (j), context->lookup_flag, &property))
{ {
if (HB_UNLIKELY (j + count - i == end)) if (unlikely (j + count - i == end))
return false; return false;
j++; j++;
} }
@ -376,7 +376,7 @@ struct Ligature
if (!(property & HB_OT_LAYOUT_GLYPH_CLASS_MARK)) if (!(property & HB_OT_LAYOUT_GLYPH_CLASS_MARK))
is_mark = false; is_mark = false;
if (HB_LIKELY (IN_GLYPH (j) != component[i])) if (likely (IN_GLYPH (j) != component[i]))
return false; return false;
} }
/* This is just a guess ... */ /* This is just a guess ... */
@ -477,7 +477,7 @@ struct LigatureSubstFormat1
bool first_is_mark = !!(context->property & HB_OT_LAYOUT_GLYPH_CLASS_MARK); bool first_is_mark = !!(context->property & HB_OT_LAYOUT_GLYPH_CLASS_MARK);
unsigned int index = (this+coverage) (glyph_id); unsigned int index = (this+coverage) (glyph_id);
if (HB_LIKELY (index == NOT_COVERED)) if (likely (index == NOT_COVERED))
return false; return false;
const LigatureSet &lig_set = this+ligatureSet[index]; const LigatureSet &lig_set = this+ligatureSet[index];
@ -568,7 +568,7 @@ struct ExtensionSubst : Extension
inline const struct SubstLookupSubTable& get_subtable (void) const inline const struct SubstLookupSubTable& get_subtable (void) const
{ {
unsigned int offset = get_offset (); unsigned int offset = get_offset ();
if (HB_UNLIKELY (!offset)) return Null(SubstLookupSubTable); if (unlikely (!offset)) return Null(SubstLookupSubTable);
return StructAtOffset<SubstLookupSubTable> (*this, offset); return StructAtOffset<SubstLookupSubTable> (*this, offset);
} }
@ -588,11 +588,11 @@ struct ReverseChainSingleSubstFormat1
inline bool apply (APPLY_ARG_DEF) const inline bool apply (APPLY_ARG_DEF) const
{ {
TRACE_APPLY (); TRACE_APPLY ();
if (HB_UNLIKELY (context_length != NO_CONTEXT)) if (unlikely (context_length != NO_CONTEXT))
return false; /* No chaining to this type */ return false; /* No chaining to this type */
unsigned int index = (this+coverage) (IN_CURGLYPH ()); unsigned int index = (this+coverage) (IN_CURGLYPH ());
if (HB_LIKELY (index == NOT_COVERED)) if (likely (index == NOT_COVERED))
return false; return false;
const OffsetArrayOf<Coverage> &lookahead = StructAfter<OffsetArrayOf<Coverage> > (backtrack); const OffsetArrayOf<Coverage> &lookahead = StructAfter<OffsetArrayOf<Coverage> > (backtrack);
@ -753,7 +753,7 @@ struct SubstLookup : Lookup
inline bool is_reverse (void) const inline bool is_reverse (void) const
{ {
unsigned int type = get_type (); unsigned int type = get_type ();
if (HB_UNLIKELY (type == SubstLookupSubTable::Extension)) if (unlikely (type == SubstLookupSubTable::Extension))
return CastR<ExtensionSubst> (get_subtable(0)).is_reverse (); return CastR<ExtensionSubst> (get_subtable(0)).is_reverse ();
return lookup_type_is_reverse (type); return lookup_type_is_reverse (type);
} }
@ -774,7 +774,7 @@ struct SubstLookup : Lookup
if (!_hb_ot_layout_check_glyph_property (layout_context->face, IN_CURINFO (), context->lookup_flag, &context->property)) if (!_hb_ot_layout_check_glyph_property (layout_context->face, IN_CURINFO (), context->lookup_flag, &context->property))
return false; return false;
if (HB_UNLIKELY (lookup_type == SubstLookupSubTable::Extension)) if (unlikely (lookup_type == SubstLookupSubTable::Extension))
{ {
/* The spec says all subtables should have the same type. /* The spec says all subtables should have the same type.
* This is specially important if one has a reverse type! * This is specially important if one has a reverse type!
@ -802,10 +802,10 @@ struct SubstLookup : Lookup
{ {
bool ret = false; bool ret = false;
if (HB_UNLIKELY (!buffer->in_length)) if (unlikely (!buffer->in_length))
return false; return false;
if (HB_LIKELY (!is_reverse ())) if (likely (!is_reverse ()))
{ {
/* in/out forward substitution */ /* in/out forward substitution */
_hb_buffer_clear_output (buffer); _hb_buffer_clear_output (buffer);
@ -843,7 +843,7 @@ struct SubstLookup : Lookup
inline bool sanitize (SANITIZE_ARG_DEF) { inline bool sanitize (SANITIZE_ARG_DEF) {
TRACE_SANITIZE (); TRACE_SANITIZE ();
if (HB_UNLIKELY (!Lookup::sanitize (SANITIZE_ARG))) return false; if (unlikely (!Lookup::sanitize (SANITIZE_ARG))) return false;
OffsetArrayOf<SubstLookupSubTable> &list = CastR<OffsetArrayOf<SubstLookupSubTable> > (subTable); OffsetArrayOf<SubstLookupSubTable> &list = CastR<OffsetArrayOf<SubstLookupSubTable> > (subTable);
return SANITIZE_THIS (list); return SANITIZE_THIS (list);
} }
@ -872,7 +872,7 @@ struct GSUB : GSUBGPOS
inline bool sanitize (SANITIZE_ARG_DEF) { inline bool sanitize (SANITIZE_ARG_DEF) {
TRACE_SANITIZE (); TRACE_SANITIZE ();
if (HB_UNLIKELY (!GSUBGPOS::sanitize (SANITIZE_ARG))) return false; if (unlikely (!GSUBGPOS::sanitize (SANITIZE_ARG))) return false;
OffsetTo<SubstLookupList> &list = CastR<OffsetTo<SubstLookupList> > (lookupList); OffsetTo<SubstLookupList> &list = CastR<OffsetTo<SubstLookupList> > (lookupList);
return SANITIZE_THIS (list); return SANITIZE_THIS (list);
} }
@ -891,16 +891,16 @@ inline bool ExtensionSubst::apply (APPLY_ARG_DEF) const
inline bool ExtensionSubst::sanitize (SANITIZE_ARG_DEF) inline bool ExtensionSubst::sanitize (SANITIZE_ARG_DEF)
{ {
TRACE_SANITIZE (); TRACE_SANITIZE ();
if (HB_UNLIKELY (!Extension::sanitize (SANITIZE_ARG))) return false; if (unlikely (!Extension::sanitize (SANITIZE_ARG))) return false;
unsigned int offset = get_offset (); unsigned int offset = get_offset ();
if (HB_UNLIKELY (!offset)) return true; if (unlikely (!offset)) return true;
return SANITIZE (StructAtOffset<SubstLookupSubTable> (*this, offset)); return SANITIZE (StructAtOffset<SubstLookupSubTable> (*this, offset));
} }
inline bool ExtensionSubst::is_reverse (void) const inline bool ExtensionSubst::is_reverse (void) const
{ {
unsigned int type = get_type (); unsigned int type = get_type ();
if (HB_UNLIKELY (type == SubstLookupSubTable::Extension)) if (unlikely (type == SubstLookupSubTable::Extension))
return CastR<ExtensionSubst> (get_subtable()).is_reverse (); return CastR<ExtensionSubst> (get_subtable()).is_reverse ();
return SubstLookup::lookup_type_is_reverse (type); return SubstLookup::lookup_type_is_reverse (type);
} }
@ -910,10 +910,10 @@ static inline bool substitute_lookup (APPLY_ARG_DEF, unsigned int lookup_index)
const GSUB &gsub = *(layout_context->face->ot_layout.gsub); const GSUB &gsub = *(layout_context->face->ot_layout.gsub);
const SubstLookup &l = gsub.get_lookup (lookup_index); const SubstLookup &l = gsub.get_lookup (lookup_index);
if (HB_UNLIKELY (context->nesting_level_left == 0)) if (unlikely (context->nesting_level_left == 0))
return false; return false;
if (HB_UNLIKELY (context_length < 1)) if (unlikely (context_length < 1))
return false; return false;
return l.apply_once (layout_context, buffer, context_length, context->nesting_level_left - 1, apply_depth + 1); return l.apply_once (layout_context, buffer, context_length, context->nesting_level_left - 1, apply_depth + 1);

View File

@ -100,19 +100,19 @@ static inline bool match_input (APPLY_ARG_DEF,
{ {
unsigned int i, j; unsigned int i, j;
unsigned int end = MIN (buffer->in_length, buffer->in_pos + context_length); unsigned int end = MIN (buffer->in_length, buffer->in_pos + context_length);
if (HB_UNLIKELY (buffer->in_pos + count > end)) if (unlikely (buffer->in_pos + count > end))
return false; return false;
for (i = 1, j = buffer->in_pos + 1; i < count; i++, j++) for (i = 1, j = buffer->in_pos + 1; i < count; i++, j++)
{ {
while (_hb_ot_layout_skip_mark (layout_context->face, IN_INFO (j), context->lookup_flag, NULL)) while (_hb_ot_layout_skip_mark (layout_context->face, IN_INFO (j), context->lookup_flag, NULL))
{ {
if (HB_UNLIKELY (j + count - i == end)) if (unlikely (j + count - i == end))
return false; return false;
j++; j++;
} }
if (HB_LIKELY (!match_func (IN_GLYPH (j), input[i - 1], match_data))) if (likely (!match_func (IN_GLYPH (j), input[i - 1], match_data)))
return false; return false;
} }
@ -127,19 +127,19 @@ static inline bool match_backtrack (APPLY_ARG_DEF,
match_func_t match_func, match_func_t match_func,
const char *match_data) const char *match_data)
{ {
if (HB_UNLIKELY (buffer->out_pos < count)) if (unlikely (buffer->out_pos < count))
return false; return false;
for (unsigned int i = 0, j = buffer->out_pos - 1; i < count; i++, j--) for (unsigned int i = 0, j = buffer->out_pos - 1; i < count; i++, j--)
{ {
while (_hb_ot_layout_skip_mark (layout_context->face, OUT_INFO (j), context->lookup_flag, NULL)) while (_hb_ot_layout_skip_mark (layout_context->face, OUT_INFO (j), context->lookup_flag, NULL))
{ {
if (HB_UNLIKELY (j + 1 == count - i)) if (unlikely (j + 1 == count - i))
return false; return false;
j--; j--;
} }
if (HB_LIKELY (!match_func (OUT_GLYPH (j), backtrack[i], match_data))) if (likely (!match_func (OUT_GLYPH (j), backtrack[i], match_data)))
return false; return false;
} }
@ -155,19 +155,19 @@ static inline bool match_lookahead (APPLY_ARG_DEF,
{ {
unsigned int i, j; unsigned int i, j;
unsigned int end = MIN (buffer->in_length, buffer->in_pos + context_length); unsigned int end = MIN (buffer->in_length, buffer->in_pos + context_length);
if (HB_UNLIKELY (buffer->in_pos + offset + count > end)) if (unlikely (buffer->in_pos + offset + count > end))
return false; return false;
for (i = 0, j = buffer->in_pos + offset; i < count; i++, j++) for (i = 0, j = buffer->in_pos + offset; i < count; i++, j++)
{ {
while (_hb_ot_layout_skip_mark (layout_context->face, OUT_INFO (j), context->lookup_flag, NULL)) while (_hb_ot_layout_skip_mark (layout_context->face, OUT_INFO (j), context->lookup_flag, NULL))
{ {
if (HB_UNLIKELY (j + count - i == end)) if (unlikely (j + count - i == end))
return false; return false;
j++; j++;
} }
if (HB_LIKELY (!match_func (IN_GLYPH (j), lookahead[i], match_data))) if (likely (!match_func (IN_GLYPH (j), lookahead[i], match_data)))
return false; return false;
} }
@ -198,7 +198,7 @@ static inline bool apply_lookup (APPLY_ARG_DEF,
apply_lookup_func_t apply_func) apply_lookup_func_t apply_func)
{ {
unsigned int end = MIN (buffer->in_length, buffer->in_pos + context_length); unsigned int end = MIN (buffer->in_length, buffer->in_pos + context_length);
if (HB_UNLIKELY (buffer->in_pos + count > end)) if (unlikely (buffer->in_pos + count > end))
return false; return false;
/* TODO We don't support lookupRecord arrays that are not increasing: /* TODO We don't support lookupRecord arrays that are not increasing:
@ -212,7 +212,7 @@ static inline bool apply_lookup (APPLY_ARG_DEF,
{ {
while (_hb_ot_layout_skip_mark (layout_context->face, IN_CURINFO (), context->lookup_flag, NULL)) while (_hb_ot_layout_skip_mark (layout_context->face, IN_CURINFO (), context->lookup_flag, NULL))
{ {
if (HB_UNLIKELY (buffer->in_pos == end)) if (unlikely (buffer->in_pos == end))
return true; return true;
/* No lookup applied for this index */ /* No lookup applied for this index */
_hb_buffer_next_glyph (buffer); _hb_buffer_next_glyph (buffer);
@ -229,7 +229,7 @@ static inline bool apply_lookup (APPLY_ARG_DEF,
lookupCount--; lookupCount--;
/* Err, this is wrong if the lookup jumped over some glyphs */ /* Err, this is wrong if the lookup jumped over some glyphs */
i += buffer->in_pos - old_pos; i += buffer->in_pos - old_pos;
if (HB_UNLIKELY (buffer->in_pos == end)) if (unlikely (buffer->in_pos == end))
return true; return true;
if (!done) if (!done)
@ -345,7 +345,7 @@ struct ContextFormat1
{ {
TRACE_APPLY (); TRACE_APPLY ();
unsigned int index = (this+coverage) (IN_CURGLYPH ()); unsigned int index = (this+coverage) (IN_CURGLYPH ());
if (HB_LIKELY (index == NOT_COVERED)) if (likely (index == NOT_COVERED))
return false; return false;
const RuleSet &rule_set = this+ruleSet[index]; const RuleSet &rule_set = this+ruleSet[index];
@ -382,7 +382,7 @@ struct ContextFormat2
{ {
TRACE_APPLY (); TRACE_APPLY ();
unsigned int index = (this+coverage) (IN_CURGLYPH ()); unsigned int index = (this+coverage) (IN_CURGLYPH ());
if (HB_LIKELY (index == NOT_COVERED)) if (likely (index == NOT_COVERED))
return false; return false;
const ClassDef &class_def = this+classDef; const ClassDef &class_def = this+classDef;
@ -427,7 +427,7 @@ struct ContextFormat3
{ {
TRACE_APPLY (); TRACE_APPLY ();
unsigned int index = (this+coverage[0]) (IN_CURGLYPH ()); unsigned int index = (this+coverage[0]) (IN_CURGLYPH ());
if (HB_LIKELY (index == NOT_COVERED)) if (likely (index == NOT_COVERED))
return false; return false;
const LookupRecord &lookupRecord = StructAtOffset<LookupRecord> (coverage, coverage[0].get_size () * glyphCount); const LookupRecord &lookupRecord = StructAtOffset<LookupRecord> (coverage, coverage[0].get_size () * glyphCount);
@ -520,7 +520,7 @@ static inline bool chain_context_lookup (APPLY_ARG_DEF,
ChainContextLookupContext &lookup_context) ChainContextLookupContext &lookup_context)
{ {
/* First guess */ /* First guess */
if (HB_UNLIKELY (buffer->out_pos < backtrackCount || if (unlikely (buffer->out_pos < backtrackCount ||
buffer->in_pos + inputCount + lookaheadCount > buffer->in_length || buffer->in_pos + inputCount + lookaheadCount > buffer->in_length ||
inputCount + lookaheadCount > context_length)) inputCount + lookaheadCount > context_length))
return false; return false;
@ -629,7 +629,7 @@ struct ChainContextFormat1
{ {
TRACE_APPLY (); TRACE_APPLY ();
unsigned int index = (this+coverage) (IN_CURGLYPH ()); unsigned int index = (this+coverage) (IN_CURGLYPH ());
if (HB_LIKELY (index == NOT_COVERED)) if (likely (index == NOT_COVERED))
return false; return false;
const ChainRuleSet &rule_set = this+ruleSet[index]; const ChainRuleSet &rule_set = this+ruleSet[index];
@ -665,7 +665,7 @@ struct ChainContextFormat2
{ {
TRACE_APPLY (); TRACE_APPLY ();
unsigned int index = (this+coverage) (IN_CURGLYPH ()); unsigned int index = (this+coverage) (IN_CURGLYPH ());
if (HB_LIKELY (index == NOT_COVERED)) if (likely (index == NOT_COVERED))
return false; return false;
const ClassDef &backtrack_class_def = this+backtrackClassDef; const ClassDef &backtrack_class_def = this+backtrackClassDef;
@ -728,7 +728,7 @@ struct ChainContextFormat3
const OffsetArrayOf<Coverage> &input = StructAfter<OffsetArrayOf<Coverage> > (backtrack); const OffsetArrayOf<Coverage> &input = StructAfter<OffsetArrayOf<Coverage> > (backtrack);
unsigned int index = (this+input[0]) (IN_CURGLYPH ()); unsigned int index = (this+input[0]) (IN_CURGLYPH ());
if (HB_LIKELY (index == NOT_COVERED)) if (likely (index == NOT_COVERED))
return false; return false;
const OffsetArrayOf<Coverage> &lookahead = StructAfter<OffsetArrayOf<Coverage> > (input); const OffsetArrayOf<Coverage> &lookahead = StructAfter<OffsetArrayOf<Coverage> > (input);
@ -912,7 +912,7 @@ struct GSUBGPOS
inline bool sanitize (SANITIZE_ARG_DEF) { inline bool sanitize (SANITIZE_ARG_DEF) {
TRACE_SANITIZE (); TRACE_SANITIZE ();
if (!SANITIZE (version)) return false; if (!SANITIZE (version)) return false;
if (HB_UNLIKELY (version.major != 1)) return false; if (unlikely (version.major != 1)) return false;
return SANITIZE_THIS3 (scriptList, featureList, lookupList); return SANITIZE_THIS3 (scriptList, featureList, lookupList);
} }

View File

@ -75,19 +75,19 @@ _hb_ot_layout_fini (hb_face_t *face)
static const GDEF& static const GDEF&
_get_gdef (hb_face_t *face) _get_gdef (hb_face_t *face)
{ {
return HB_LIKELY (face->ot_layout.gdef) ? *face->ot_layout.gdef : Null(GDEF); return likely (face->ot_layout.gdef) ? *face->ot_layout.gdef : Null(GDEF);
} }
static const GSUB& static const GSUB&
_get_gsub (hb_face_t *face) _get_gsub (hb_face_t *face)
{ {
return HB_LIKELY (face->ot_layout.gsub) ? *face->ot_layout.gsub : Null(GSUB); return likely (face->ot_layout.gsub) ? *face->ot_layout.gsub : Null(GSUB);
} }
static const GPOS& static const GPOS&
_get_gpos (hb_face_t *face) _get_gpos (hb_face_t *face)
{ {
return HB_LIKELY (face->ot_layout.gpos) ? *face->ot_layout.gpos : Null(GPOS); return likely (face->ot_layout.gpos) ? *face->ot_layout.gpos : Null(GPOS);
} }
@ -219,7 +219,7 @@ _hb_ot_layout_set_glyph_class (hb_face_t *face,
hb_ot_layout_class_t gdef_klass; hb_ot_layout_class_t gdef_klass;
unsigned int len = layout->new_gdef.len; unsigned int len = layout->new_gdef.len;
if (HB_UNLIKELY (glyph > 65535)) if (unlikely (glyph > 65535))
return; return;
/* XXX this is not threadsafe */ /* XXX this is not threadsafe */
@ -235,7 +235,7 @@ _hb_ot_layout_set_glyph_class (hb_face_t *face,
new_len = 65536; new_len = 65536;
new_klasses = (unsigned char *) realloc (layout->new_gdef.klasses, new_len * sizeof (unsigned char)); new_klasses = (unsigned char *) realloc (layout->new_gdef.klasses, new_len * sizeof (unsigned char));
if (HB_UNLIKELY (!new_klasses)) if (unlikely (!new_klasses))
return; return;
memset (new_klasses + len, 0, new_len - len); memset (new_klasses + len, 0, new_len - len);
@ -290,7 +290,7 @@ hb_ot_layout_build_glyph_classes (hb_face_t *face,
hb_ot_layout_t *layout = &face->ot_layout; hb_ot_layout_t *layout = &face->ot_layout;
if (HB_UNLIKELY (!count || !glyphs || !klasses)) if (unlikely (!count || !glyphs || !klasses))
return; return;
if (layout->new_gdef.len == 0) { if (layout->new_gdef.len == 0) {

View File

@ -128,7 +128,7 @@ hb_ot_tags_from_script (hb_script_t script)
{ {
static const hb_tag_t def_tag[] = {HB_OT_TAG_DEFAULT_SCRIPT, HB_TAG_NONE}; static const hb_tag_t def_tag[] = {HB_OT_TAG_DEFAULT_SCRIPT, HB_TAG_NONE};
if (HB_UNLIKELY ((unsigned int) script >= ARRAY_LENGTH (ot_scripts))) if (unlikely ((unsigned int) script >= ARRAY_LENGTH (ot_scripts)))
return def_tag; return def_tag;
return ot_scripts[script]; return ot_scripts[script];

View File

@ -104,11 +104,11 @@
_hb_boolean_var_ = 0; \ _hb_boolean_var_ = 0; \
_hb_boolean_var_; \ _hb_boolean_var_; \
}) })
#define HB_LIKELY(expr) (__builtin_expect (_HB_BOOLEAN_EXPR(expr), 1)) #define likely(expr) (__builtin_expect (_HB_BOOLEAN_EXPR(expr), 1))
#define HB_UNLIKELY(expr) (__builtin_expect (_HB_BOOLEAN_EXPR(expr), 0)) #define unlikely(expr) (__builtin_expect (_HB_BOOLEAN_EXPR(expr), 0))
#else #else
#define HB_LIKELY(expr) (expr) #define likely(expr) (expr)
#define HB_UNLIKELY(expr) (expr) #define unlikely(expr) (expr)
#endif #endif
#ifndef __GNUC__ #ifndef __GNUC__

View File

@ -38,9 +38,9 @@
static inline hb_bool_t static inline hb_bool_t
is_variation_selector (hb_codepoint_t unicode) is_variation_selector (hb_codepoint_t unicode)
{ {
return HB_UNLIKELY ((unicode >= 0x180B && unicode <= 0x180D) || /* MONGOLIAN FREE VARIATION SELECTOR ONE..THREE */ return unlikely ((unicode >= 0x180B && unicode <= 0x180D) || /* MONGOLIAN FREE VARIATION SELECTOR ONE..THREE */
(unicode >= 0xFE00 && unicode <= 0xFE0F) || /* VARIATION SELECTOR-1..16 */ (unicode >= 0xFE00 && unicode <= 0xFE0F) || /* VARIATION SELECTOR-1..16 */
(unicode >= 0xE0100 && unicode <= 0xE01EF)); /* VARIATION SELECTOR-17..256 */ (unicode >= 0xE0100 && unicode <= 0xE01EF)); /* VARIATION SELECTOR-17..256 */
} }
static void static void
@ -95,11 +95,11 @@ hb_map_glyphs (hb_font_t *font,
{ {
unsigned int count; unsigned int count;
if (HB_UNLIKELY (!buffer->in_length)) if (unlikely (!buffer->in_length))
return; return;
count = buffer->in_length - 1; count = buffer->in_length - 1;
for (buffer->in_pos = 0; buffer->in_pos < count; buffer->in_pos++) { for (buffer->in_pos = 0; buffer->in_pos < count; buffer->in_pos++) {
if (HB_UNLIKELY (is_variation_selector (IN_NEXTGLYPH()))) { if (unlikely (is_variation_selector (IN_NEXTGLYPH()))) {
IN_CURGLYPH() = hb_font_get_glyph (font, face, IN_CURGLYPH(), IN_NEXTGLYPH()); IN_CURGLYPH() = hb_font_get_glyph (font, face, IN_CURGLYPH(), IN_NEXTGLYPH());
buffer->in_pos++; buffer->in_pos++;
} else { } else {

View File

@ -294,7 +294,7 @@ const hb_direction_t horiz_dir[] =
HB_INTERNAL hb_direction_t HB_INTERNAL hb_direction_t
_hb_script_get_horizontal_direction (hb_script_t script) _hb_script_get_horizontal_direction (hb_script_t script)
{ {
if (HB_UNLIKELY ((unsigned int) script >= ARRAY_LENGTH (horiz_dir))) if (unlikely ((unsigned int) script >= ARRAY_LENGTH (horiz_dir)))
return HB_DIRECTION_LTR; return HB_DIRECTION_LTR;
return horiz_dir[script]; return horiz_dir[script];