[HarfBuzz] harfbuzz-ng: Branch 'master' - 8 commits

Behdad Esfahbod behdad at kemper.freedesktop.org
Mon May 3 20:11:27 PDT 2010


 src/hb-buffer.c                      |   14 +++----
 src/hb-font.cc                       |    6 +--
 src/hb-ft.c                          |   14 +++----
 src/hb-language.c                    |    2 -
 src/hb-object-private.h              |   12 +++---
 src/hb-open-file-private.hh          |   21 ++++++-----
 src/hb-open-type-private.hh          |   57 +++++++++++++++----------------
 src/hb-ot-layout-common-private.hh   |   16 ++++----
 src/hb-ot-layout-gdef-private.hh     |    2 -
 src/hb-ot-layout-gpos-private.hh     |   64 +++++++++++++++++------------------
 src/hb-ot-layout-gsub-private.hh     |   52 ++++++++++++++--------------
 src/hb-ot-layout-gsubgpos-private.hh |   40 ++++++++++-----------
 src/hb-ot-layout.cc                  |   12 +++---
 src/hb-ot-tag.c                      |    2 -
 src/hb-private.h                     |   12 +++---
 src/hb-shape.c                       |   10 ++---
 src/hb-unicode.c                     |    2 -
 17 files changed, 170 insertions(+), 168 deletions(-)

New commits:
commit 710500a93ecc2a0c595045602aa367073485ff91
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Mon May 3 23:11:16 2010 -0400

    Comment new SFNT tags

diff --git a/src/hb-open-file-private.hh b/src/hb-open-file-private.hh
index e9891be..f25522e 100644
--- a/src/hb-open-file-private.hh
+++ b/src/hb-open-file-private.hh
@@ -190,11 +190,11 @@ struct TTCHeader
 
 struct OpenTypeFontFile
 {
-  static const hb_tag_t CFFTag		= HB_TAG ('O','T','T','O');
-  static const hb_tag_t TrueTypeTag	= HB_TAG ( 0 , 1 , 0 , 0 );
-  static const hb_tag_t TTCTag		= HB_TAG ('t','t','c','f');
-  static const hb_tag_t TrueTag		= HB_TAG ('t','r','u','e');
-  static const hb_tag_t Typ1Tag		= HB_TAG ('t','y','p','1');
+  static const hb_tag_t CFFTag		= HB_TAG ('O','T','T','O'); /* OpenType with Postscript outlines */
+  static const hb_tag_t TrueTypeTag	= HB_TAG ( 0 , 1 , 0 , 0 ); /* OpenType with TrueType outlines */
+  static const hb_tag_t TTCTag		= HB_TAG ('t','t','c','f'); /* TrueType Collection */
+  static const hb_tag_t TrueTag		= HB_TAG ('t','r','u','e'); /* Apple obsolete tag */
+  static const hb_tag_t Typ1Tag		= HB_TAG ('t','y','p','1'); /* Apple obsolete tag */
 
   inline hb_tag_t get_tag (void) const { return u.tag; }
 
commit 64d3fc8d0dada673245cc8c0b1c12cd849b30997
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Mon May 3 22:51:19 2010 -0400

    Cosmetic: Rename HB_LIKELY/HB_UNLIKELY to likely/unlikely

diff --git a/src/hb-buffer.c b/src/hb-buffer.c
index f169c35..adec7c1 100644
--- a/src/hb-buffer.c
+++ b/src/hb-buffer.c
@@ -258,7 +258,7 @@ hb_buffer_clear_positions (hb_buffer_t *buffer)
   buffer->have_output = FALSE;
   buffer->have_positions = TRUE;
 
-  if (HB_UNLIKELY (!buffer->positions))
+  if (unlikely (!buffer->positions))
   {
     buffer->positions = calloc (buffer->allocated, sizeof (buffer->positions[0]));
     return;
@@ -510,7 +510,7 @@ reverse_range (hb_buffer_t *buffer,
 void
 hb_buffer_reverse (hb_buffer_t *buffer)
 {
-  if (HB_UNLIKELY (!buffer->in_length))
+  if (unlikely (!buffer->in_length))
     return;
 
   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;
 
-  if (HB_UNLIKELY (!buffer->in_length))
+  if (unlikely (!buffer->in_length))
     return;
 
   hb_buffer_reverse (buffer);
@@ -569,7 +569,7 @@ hb_utf8_next (const uint8_t *text,
   unsigned int 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;
     return text + 1;
   } else {
@@ -578,7 +578,7 @@ hb_utf8_next (const uint8_t *text,
     result = c & mask;
     for (i = 1; i < len; i++)
       {
-	if (HB_UNLIKELY ((text[i] & 0xc0) != 0x80))
+	if (unlikely ((text[i] & 0xc0) != 0x80))
 	  {
 	    *unicode = -1;
 	    return text + 1;
@@ -610,10 +610,10 @@ hb_utf16_next (const uint16_t *text,
 {
   uint16_t c = *text++;
 
-  if (HB_UNLIKELY (c >= 0xd800 && c < 0xdc00)) {
+  if (unlikely (c >= 0xd800 && c < 0xdc00)) {
     /* high surrogate */
     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 */
       *unicode = ((hb_codepoint_t) ((c) - 0xd800) * 0x400 + (l) - 0xdc00 + 0x10000);
        text++;
diff --git a/src/hb-font.cc b/src/hb-font.cc
index a17cab5..b8b151b 100644
--- a/src/hb-font.cc
+++ b/src/hb-font.cc
@@ -274,7 +274,7 @@ _hb_face_for_data_closure_create (hb_blob_t *blob, unsigned int index)
   hb_face_for_data_closure_t *closure;
 
   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;
 
   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
 _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);
     free (closure);
   }
@@ -361,7 +361,7 @@ hb_face_get_table (hb_face_t *face,
 {
   hb_blob_t *blob;
 
-  if (HB_UNLIKELY (!face || !face->get_table))
+  if (unlikely (!face || !face->get_table))
     return &_hb_blob_nil;
 
   blob = face->get_table (tag, face->user_data);
diff --git a/src/hb-ft.c b/src/hb-ft.c
index f245a04..e6f3e84 100644
--- a/src/hb-ft.c
+++ b/src/hb-ft.c
@@ -43,7 +43,7 @@ hb_ft_get_glyph (hb_font_t *font HB_UNUSED,
   FT_Face ft_face = (FT_Face) user_data;
 
 #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);
     if (glyph)
       return glyph;
@@ -67,13 +67,13 @@ hb_ft_get_contour_point (hb_font_t *font HB_UNUSED,
 
   /* 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;
 
-  if (HB_UNLIKELY (ft_face->glyph->format != FT_GLYPH_FORMAT_OUTLINE))
+  if (unlikely (ft_face->glyph->format != FT_GLYPH_FORMAT_OUTLINE))
       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;
 
   *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_offset = metrics->y_offset = 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. */
     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_Error error;
 
-  if (HB_UNLIKELY (tag == HB_TAG_NONE))
+  if (unlikely (tag == HB_TAG_NONE))
     return hb_blob_create_empty ();
 
   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_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)
       ft_face->generic.finalizer (ft_face);
diff --git a/src/hb-language.c b/src/hb-language.c
index 5d7286b..d57cbdf 100644
--- a/src/hb-language.c
+++ b/src/hb-language.c
@@ -89,7 +89,7 @@ hb_language_from_string (const char *str)
     if (lang_equal (str, 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);
     const char **new_langs = realloc (langs, new_alloced * sizeof (langs[0]));
     if (!new_langs)
diff --git a/src/hb-object-private.h b/src/hb-object-private.h
index 2f5429f..e99bfbe 100644
--- a/src/hb-object-private.h
+++ b/src/hb-object-private.h
@@ -82,7 +82,7 @@ _hb_object_debug_out (const void *obj,
 /* Object allocation and lifecycle manamgement macros */
 
 #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) \
     HB_REFERENCE_COUNT_INIT (obj->ref_count, 1)
@@ -93,7 +93,7 @@ _hb_object_debug_out (const void *obj,
   } HB_STMT_END
 
 #define HB_OBJECT_DO_CREATE(Type, obj) \
-  HB_LIKELY (( \
+  likely (( \
 	       (void) ( \
 		 ((obj) = (Type *) calloc (1, sizeof (Type))) && \
 		 HB_OBJECT_DO_INIT_EXPR (obj) && \
@@ -105,7 +105,7 @@ _hb_object_debug_out (const void *obj,
 #define HB_OBJECT_DO_REFERENCE(obj) \
   HB_STMT_START { \
     int old_count; \
-    if (HB_UNLIKELY (!(obj) || HB_OBJECT_IS_INERT (obj))) \
+    if (unlikely (!(obj) || HB_OBJECT_IS_INERT (obj))) \
       return obj; \
     HB_OBJECT_DEBUG_OUT (obj); \
     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) \
   HB_STMT_START { \
-    if (HB_UNLIKELY (!(obj) || HB_OBJECT_IS_INERT (obj))) \
+    if (unlikely (!(obj) || HB_OBJECT_IS_INERT (obj))) \
       return 0; \
     return HB_REFERENCE_COUNT_GET_VALUE (obj->ref_count); \
   } HB_STMT_END
@@ -123,7 +123,7 @@ _hb_object_debug_out (const void *obj,
 #define HB_OBJECT_DO_DESTROY(obj) \
   HB_STMT_START { \
     int old_count; \
-    if (HB_UNLIKELY (!(obj) || HB_OBJECT_IS_INERT (obj))) \
+    if (unlikely (!(obj) || HB_OBJECT_IS_INERT (obj))) \
       return; \
     HB_OBJECT_DEBUG_OUT (obj); \
     old_count = hb_reference_count_dec (obj->ref_count); \
diff --git a/src/hb-open-file-private.hh b/src/hb-open-file-private.hh
index 5f13f55..e9891be 100644
--- a/src/hb-open-file-private.hh
+++ b/src/hb-open-file-private.hh
@@ -70,7 +70,7 @@ typedef struct OffsetTable
   { return numTables; }
   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];
   }
   inline bool find_table_index (hb_tag_t tag, unsigned int *table_index) const
diff --git a/src/hb-open-type-private.hh b/src/hb-open-type-private.hh
index 75bd23d..a3e6f4d 100644
--- a/src/hb-open-type-private.hh
+++ b/src/hb-open-type-private.hh
@@ -205,7 +205,7 @@ _hb_sanitize_array (SANITIZE_ARG_DEF,
 	     context->start, context->end,
 	     !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
@@ -227,22 +227,22 @@ _hb_sanitize_edit (SANITIZE_ARG_DEF,
   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 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_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_SELF() SANITIZE_OBJ (*this)
 #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) \
 	(SANITIZE_OBJ (Obj) && \
@@ -445,7 +445,7 @@ struct GenericOffsetTo : OffsetType
   inline const Type& operator () (const void *base) const
   {
     unsigned int offset = *this;
-    if (HB_UNLIKELY (!offset)) return Null(Type);
+    if (unlikely (!offset)) return Null(Type);
     return StructAtOffset<Type> (*CharP(base), offset);
   }
 
@@ -453,21 +453,21 @@ struct GenericOffsetTo : OffsetType
     TRACE_SANITIZE ();
     if (!SANITIZE_SELF ()) return false;
     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);
   }
   inline bool sanitize (SANITIZE_ARG_DEF, void *base, void *base2) {
     TRACE_SANITIZE ();
     if (!SANITIZE_SELF ()) return false;
     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);
   }
   inline bool sanitize (SANITIZE_ARG_DEF, void *base, unsigned int user_data) {
     TRACE_SANITIZE ();
     if (!SANITIZE_SELF ()) return false;
     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);
   }
 };
@@ -494,7 +494,7 @@ struct GenericArrayOf
   const Type *sub_array (unsigned int start_offset, unsigned int *pcount /* IN/OUT */) const
   {
     unsigned int count = len;
-    if (HB_UNLIKELY (start_offset > count))
+    if (unlikely (start_offset > count))
       count = 0;
     else
       count -= start_offset;
@@ -505,7 +505,7 @@ struct GenericArrayOf
 
   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];
   }
   inline unsigned int get_size () const
@@ -518,7 +518,7 @@ struct GenericArrayOf
 
   inline bool sanitize (SANITIZE_ARG_DEF) {
     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,
      * we do not need to call their sanitize() as we already did
      * 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) {
     TRACE_SANITIZE ();
-    if (!HB_LIKELY (sanitize_shallow (SANITIZE_ARG))) return false;
+    if (!likely (sanitize_shallow (SANITIZE_ARG))) return false;
     unsigned int count = len;
     for (unsigned int i = 0; i < count; i++)
       if (!array()[i].sanitize (SANITIZE_ARG, base))
@@ -544,7 +544,7 @@ struct GenericArrayOf
   }
   inline bool sanitize (SANITIZE_ARG_DEF, void *base, void *base2) {
     TRACE_SANITIZE ();
-    if (!HB_LIKELY (sanitize_shallow (SANITIZE_ARG))) return false;
+    if (!likely (sanitize_shallow (SANITIZE_ARG))) return false;
     unsigned int count = len;
     for (unsigned int i = 0; i < count; i++)
       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) {
     TRACE_SANITIZE ();
-    if (!HB_LIKELY (sanitize_shallow (SANITIZE_ARG))) return false;
+    if (!likely (sanitize_shallow (SANITIZE_ARG))) return false;
     unsigned int count = len;
     for (unsigned int i = 0; i < count; i++)
       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
   {
-    if (HB_UNLIKELY (i >= this->len)) return Null(Type);
+    if (unlikely (i >= this->len)) return Null(Type);
     return this+this->array()[i];
   }
 
@@ -616,7 +616,7 @@ struct HeadlessArrayOf
 
   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];
   }
   inline unsigned int get_size () const
@@ -629,7 +629,7 @@ struct HeadlessArrayOf
 
   inline bool sanitize (SANITIZE_ARG_DEF) {
     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,
      * we do not need to call their sanitize() as we already did
      * a bound check on the aggregate array size, hence the return.
diff --git a/src/hb-ot-layout-common-private.hh b/src/hb-ot-layout-common-private.hh
index c7c6e2b..94bbff3 100644
--- a/src/hb-ot-layout-common-private.hh
+++ b/src/hb-ot-layout-common-private.hh
@@ -68,7 +68,7 @@ template <typename Type>
 struct RecordArrayOf : ArrayOf<Record<Type> > {
   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;
   }
   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
   {
-    if (HB_UNLIKELY (i >= this->len))
+    if (unlikely (i >= this->len))
       return NO_INDEX;
     return this->array()[i];
   }
@@ -272,7 +272,7 @@ struct Lookup
   inline unsigned int get_flag (void) const
   {
     unsigned int flag = lookupFlag;
-    if (HB_UNLIKELY (flag & LookupFlag::UseMarkFilteringSet))
+    if (unlikely (flag & LookupFlag::UseMarkFilteringSet))
     {
       const USHORT &markFilteringSet = StructAfter<USHORT> (subTable);
       flag += (markFilteringSet << 16);
@@ -283,8 +283,8 @@ struct Lookup
   inline bool sanitize (SANITIZE_ARG_DEF) {
     TRACE_SANITIZE ();
     /* Real sanitize of the subtables is done by GSUB/GPOS/... */
-    if (!(SANITIZE_SELF () && HB_LIKELY (subTable.sanitize (SANITIZE_ARG)))) return false;
-    if (HB_UNLIKELY (lookupFlag & LookupFlag::UseMarkFilteringSet))
+    if (!(SANITIZE_SELF () && likely (subTable.sanitize (SANITIZE_ARG)))) return false;
+    if (unlikely (lookupFlag & LookupFlag::UseMarkFilteringSet))
     {
       USHORT &markFilteringSet = StructAfter<USHORT> (subTable);
       if (!SANITIZE (markFilteringSet)) return false;
@@ -317,7 +317,7 @@ struct CoverageFormat1
   private:
   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;
     GlyphID gid;
     gid.set (glyph_id);
@@ -563,7 +563,7 @@ struct Device
   inline int get_delta (unsigned int ppem_size) const
   {
     unsigned int f = deltaFormat;
-    if (HB_UNLIKELY (f < 1 || f > 3))
+    if (unlikely (f < 1 || f > 3))
       return 0;
 
     if (ppem_size < startSize || ppem_size > endSize)
@@ -586,7 +586,7 @@ struct Device
   inline unsigned int get_size () const
   {
     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)));
   }
 
diff --git a/src/hb-ot-layout-gdef-private.hh b/src/hb-ot-layout-gdef-private.hh
index a2eed5b..e63ec73 100644
--- a/src/hb-ot-layout-gdef-private.hh
+++ b/src/hb-ot-layout-gdef-private.hh
@@ -349,7 +349,7 @@ struct GDEF
   inline bool sanitize (SANITIZE_ARG_DEF) {
     TRACE_SANITIZE ();
     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) &&
 	   SANITIZE_THIS2 (ligCaretList, markAttachClassDef) &&
 	   (version < 0x00010002 || SANITIZE_THIS (markGlyphSetsDef[0]));
diff --git a/src/hb-ot-layout-gpos-private.hh b/src/hb-ot-layout-gpos-private.hh
index fb9ec9f..a2c5a1a 100644
--- a/src/hb-ot-layout-gpos-private.hh
+++ b/src/hb-ot-layout-gpos-private.hh
@@ -326,14 +326,14 @@ struct Anchor
 struct AnchorMatrix
 {
   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];
   }
 
   inline bool sanitize (SANITIZE_ARG_DEF, unsigned int cols) {
     TRACE_SANITIZE ();
     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;
     if (!SANITIZE_ARRAY (matrix, matrix[0].get_size (), count)) return false;
     for (unsigned int i = 0; i < count; i++)
@@ -422,7 +422,7 @@ struct SinglePosFormat1
   {
     TRACE_APPLY ();
     unsigned int index = (this+coverage) (IN_CURGLYPH ());
-    if (HB_LIKELY (index == NOT_COVERED))
+    if (likely (index == NOT_COVERED))
       return false;
 
     valueFormat.apply_value (layout_context, CharP(this), values, CURPOSITION ());
@@ -459,10 +459,10 @@ struct SinglePosFormat2
   {
     TRACE_APPLY ();
     unsigned int index = (this+coverage) (IN_CURGLYPH ());
-    if (HB_LIKELY (index == NOT_COVERED))
+    if (likely (index == NOT_COVERED))
       return false;
 
-    if (HB_LIKELY (index >= valueCount))
+    if (likely (index >= valueCount))
       return false;
 
     valueFormat.apply_value (layout_context, CharP(this),
@@ -568,17 +568,17 @@ struct PairPosFormat1
   {
     TRACE_APPLY ();
     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;
 
     unsigned int index = (this+coverage) (IN_CURGLYPH ());
-    if (HB_LIKELY (index == NOT_COVERED))
+    if (likely (index == NOT_COVERED))
       return false;
 
     unsigned int j = buffer->in_pos + 1;
     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;
       j++;
     }
@@ -614,7 +614,7 @@ struct PairPosFormat1
     unsigned int len2 = valueFormat2.get_len ();
 
     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;
 
@@ -660,17 +660,17 @@ struct PairPosFormat2
   {
     TRACE_APPLY ();
     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;
 
     unsigned int index = (this+coverage) (IN_CURGLYPH ());
-    if (HB_LIKELY (index == NOT_COVERED))
+    if (likely (index == NOT_COVERED))
       return false;
 
     unsigned int j = buffer->in_pos + 1;
     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;
       j++;
     }
@@ -681,7 +681,7 @@ struct PairPosFormat2
 
     unsigned int klass1 = (this+classDef1) (IN_CURGLYPH ());
     unsigned int klass2 = (this+classDef2) (IN_GLYPH (j));
-    if (HB_UNLIKELY (klass1 >= class1Count || klass2 >= class2Count))
+    if (unlikely (klass1 >= class1Count || klass2 >= class2Count))
       return false;
 
     const Value *v = &values[record_len * (klass1 * class2Count + klass2)];
@@ -927,7 +927,7 @@ struct CursivePosFormat1
       return false;
 
     unsigned int index = (this+coverage) (IN_CURGLYPH ());
-    if (HB_LIKELY (index == NOT_COVERED))
+    if (likely (index == NOT_COVERED))
       return false;
 
     const EntryExitRecord &record = entryExitRecord[index];
@@ -1034,7 +1034,7 @@ struct MarkBasePosFormat1
   {
     TRACE_APPLY ();
     unsigned int mark_index = (this+markCoverage) (IN_CURGLYPH ());
-    if (HB_LIKELY (mark_index == NOT_COVERED))
+    if (likely (mark_index == NOT_COVERED))
       return false;
 
     /* now we search backwards for a non-mark glyph */
@@ -1042,7 +1042,7 @@ struct MarkBasePosFormat1
     unsigned int j = buffer->in_pos;
     do
     {
-      if (HB_UNLIKELY (!j))
+      if (unlikely (!j))
 	return false;
       j--;
     } 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) {
     TRACE_SANITIZE ();
     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:
@@ -1134,7 +1134,7 @@ struct MarkLigPosFormat1
   {
     TRACE_APPLY ();
     unsigned int mark_index = (this+markCoverage) (IN_CURGLYPH ());
-    if (HB_LIKELY (mark_index == NOT_COVERED))
+    if (likely (mark_index == NOT_COVERED))
       return false;
 
     /* now we search backwards for a non-mark glyph */
@@ -1142,7 +1142,7 @@ struct MarkLigPosFormat1
     unsigned int j = buffer->in_pos;
     do
     {
-      if (HB_UNLIKELY (!j))
+      if (unlikely (!j))
 	return false;
       j--;
     } 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 */
     unsigned int comp_count = lig_attach.rows;
-    if (HB_UNLIKELY (!comp_count))
+    if (unlikely (!comp_count))
       return false;
     unsigned int comp_index;
     /* 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) {
     TRACE_SANITIZE ();
     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:
@@ -1251,7 +1251,7 @@ struct MarkMarkPosFormat1
   {
     TRACE_APPLY ();
     unsigned int mark1_index = (this+mark1Coverage) (IN_CURGLYPH ());
-    if (HB_LIKELY (mark1_index == NOT_COVERED))
+    if (likely (mark1_index == NOT_COVERED))
       return false;
 
     /* 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;
     do
     {
-      if (HB_UNLIKELY (!j))
+      if (unlikely (!j))
 	return false;
       j--;
     } 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) {
     TRACE_SANITIZE ();
     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:
@@ -1373,7 +1373,7 @@ struct ExtensionPos : Extension
   inline const struct PosLookupSubTable& get_subtable (void) const
   {
     unsigned int offset = get_offset ();
-    if (HB_UNLIKELY (!offset)) return Null(PosLookupSubTable);
+    if (unlikely (!offset)) return Null(PosLookupSubTable);
     return StructAtOffset<PosLookupSubTable> (*this, offset);
   }
 
@@ -1488,7 +1488,7 @@ struct PosLookup : Lookup
   {
     bool ret = false;
 
-    if (HB_UNLIKELY (!buffer->in_length))
+    if (unlikely (!buffer->in_length))
       return false;
 
     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) {
     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);
     return SANITIZE_THIS (list);
   }
@@ -1547,7 +1547,7 @@ struct GPOS : GSUBGPOS
 
   inline bool sanitize (SANITIZE_ARG_DEF) {
     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);
     return SANITIZE_THIS (list);
   }
@@ -1566,9 +1566,9 @@ inline bool ExtensionPos::apply (APPLY_ARG_DEF) const
 inline bool ExtensionPos::sanitize (SANITIZE_ARG_DEF)
 {
   TRACE_SANITIZE ();
-  if (HB_UNLIKELY (!Extension::sanitize (SANITIZE_ARG))) return false;
+  if (unlikely (!Extension::sanitize (SANITIZE_ARG))) return false;
   unsigned int offset = get_offset ();
-  if (HB_UNLIKELY (!offset)) return true;
+  if (unlikely (!offset)) return true;
   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 PosLookup &l = gpos.get_lookup (lookup_index);
 
-  if (HB_UNLIKELY (context->nesting_level_left == 0))
+  if (unlikely (context->nesting_level_left == 0))
     return false;
 
-  if (HB_UNLIKELY (context_length < 1))
+  if (unlikely (context_length < 1))
     return false;
 
   return l.apply_once (layout_context, buffer, context_length, context->nesting_level_left - 1, apply_depth + 1);
diff --git a/src/hb-ot-layout-gsub-private.hh b/src/hb-ot-layout-gsub-private.hh
index 31de65c..889baa7 100644
--- a/src/hb-ot-layout-gsub-private.hh
+++ b/src/hb-ot-layout-gsub-private.hh
@@ -41,7 +41,7 @@ struct SingleSubstFormat1
     TRACE_APPLY ();
     hb_codepoint_t glyph_id = IN_CURGLYPH ();
     unsigned int index = (this+coverage) (glyph_id);
-    if (HB_LIKELY (index == NOT_COVERED))
+    if (likely (index == NOT_COVERED))
       return false;
 
     glyph_id += deltaGlyphID;
@@ -80,10 +80,10 @@ struct SingleSubstFormat2
     TRACE_APPLY ();
     hb_codepoint_t glyph_id = IN_CURGLYPH ();
     unsigned int index = (this+coverage) (glyph_id);
-    if (HB_LIKELY (index == NOT_COVERED))
+    if (likely (index == NOT_COVERED))
       return false;
 
-    if (HB_UNLIKELY (index >= substitute.len))
+    if (unlikely (index >= substitute.len))
       return false;
 
     glyph_id = substitute[index];
@@ -155,7 +155,7 @@ struct Sequence
   inline bool apply (APPLY_ARG_DEF) const
   {
     TRACE_APPLY ();
-    if (HB_UNLIKELY (!substitute.len))
+    if (unlikely (!substitute.len))
       return false;
 
     _hb_buffer_add_output_glyphs_be16 (buffer, 1,
@@ -200,7 +200,7 @@ struct MultipleSubstFormat1
     TRACE_APPLY ();
 
     unsigned int index = (this+coverage) (IN_CURGLYPH ());
-    if (HB_LIKELY (index == NOT_COVERED))
+    if (likely (index == NOT_COVERED))
       return false;
 
     return (this+sequence[index]).apply (APPLY_ARG);
@@ -270,12 +270,12 @@ struct AlternateSubstFormat1
     hb_codepoint_t glyph_id = IN_CURGLYPH ();
 
     unsigned int index = (this+coverage) (glyph_id);
-    if (HB_LIKELY (index == NOT_COVERED))
+    if (likely (index == NOT_COVERED))
       return false;
 
     const AlternateSet &alt_set = this+alternateSet[index];
 
-    if (HB_UNLIKELY (!alt_set.len))
+    if (unlikely (!alt_set.len))
       return false;
 
     unsigned int alt_index = 0;
@@ -287,7 +287,7 @@ struct AlternateSubstFormat1
 				    alt_set.len, alt_set.array);
 				   */
 
-    if (HB_UNLIKELY (alt_index >= alt_set.len))
+    if (unlikely (alt_index >= alt_set.len))
       return false;
 
     glyph_id = alt_set[alt_index];
@@ -360,7 +360,7 @@ struct Ligature
     unsigned int i, j;
     unsigned int count = component.len;
     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;
 
     for (i = 1, j = buffer->in_pos + 1; i < count; i++, j++)
@@ -368,7 +368,7 @@ struct Ligature
       unsigned int 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;
 	j++;
       }
@@ -376,7 +376,7 @@ struct Ligature
       if (!(property & HB_OT_LAYOUT_GLYPH_CLASS_MARK))
 	is_mark = false;
 
-      if (HB_LIKELY (IN_GLYPH (j) != component[i]))
+      if (likely (IN_GLYPH (j) != component[i]))
         return false;
     }
     /* This is just a guess ... */
@@ -477,7 +477,7 @@ struct LigatureSubstFormat1
     bool first_is_mark = !!(context->property & HB_OT_LAYOUT_GLYPH_CLASS_MARK);
 
     unsigned int index = (this+coverage) (glyph_id);
-    if (HB_LIKELY (index == NOT_COVERED))
+    if (likely (index == NOT_COVERED))
       return false;
 
     const LigatureSet &lig_set = this+ligatureSet[index];
@@ -568,7 +568,7 @@ struct ExtensionSubst : Extension
   inline const struct SubstLookupSubTable& get_subtable (void) const
   {
     unsigned int offset = get_offset ();
-    if (HB_UNLIKELY (!offset)) return Null(SubstLookupSubTable);
+    if (unlikely (!offset)) return Null(SubstLookupSubTable);
     return StructAtOffset<SubstLookupSubTable> (*this, offset);
   }
 
@@ -588,11 +588,11 @@ struct ReverseChainSingleSubstFormat1
   inline bool apply (APPLY_ARG_DEF) const
   {
     TRACE_APPLY ();
-    if (HB_UNLIKELY (context_length != NO_CONTEXT))
+    if (unlikely (context_length != NO_CONTEXT))
       return false; /* No chaining to this type */
 
     unsigned int index = (this+coverage) (IN_CURGLYPH ());
-    if (HB_LIKELY (index == NOT_COVERED))
+    if (likely (index == NOT_COVERED))
       return false;
 
     const OffsetArrayOf<Coverage> &lookahead = StructAfter<OffsetArrayOf<Coverage> > (backtrack);
@@ -753,7 +753,7 @@ struct SubstLookup : Lookup
   inline bool is_reverse (void) const
   {
     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 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))
       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.
        * This is specially important if one has a reverse type!
@@ -802,10 +802,10 @@ struct SubstLookup : Lookup
   {
     bool ret = false;
 
-    if (HB_UNLIKELY (!buffer->in_length))
+    if (unlikely (!buffer->in_length))
       return false;
 
-    if (HB_LIKELY (!is_reverse ()))
+    if (likely (!is_reverse ()))
     {
 	/* in/out forward substitution */
 	_hb_buffer_clear_output (buffer);
@@ -843,7 +843,7 @@ struct SubstLookup : Lookup
 
   inline bool sanitize (SANITIZE_ARG_DEF) {
     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);
     return SANITIZE_THIS (list);
   }
@@ -872,7 +872,7 @@ struct GSUB : GSUBGPOS
 
   inline bool sanitize (SANITIZE_ARG_DEF) {
     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);
     return SANITIZE_THIS (list);
   }
@@ -891,16 +891,16 @@ inline bool ExtensionSubst::apply (APPLY_ARG_DEF) const
 inline bool ExtensionSubst::sanitize (SANITIZE_ARG_DEF)
 {
   TRACE_SANITIZE ();
-  if (HB_UNLIKELY (!Extension::sanitize (SANITIZE_ARG))) return false;
+  if (unlikely (!Extension::sanitize (SANITIZE_ARG))) return false;
   unsigned int offset = get_offset ();
-  if (HB_UNLIKELY (!offset)) return true;
+  if (unlikely (!offset)) return true;
   return SANITIZE (StructAtOffset<SubstLookupSubTable> (*this, offset));
 }
 
 inline bool ExtensionSubst::is_reverse (void) const
 {
   unsigned int type = get_type ();
-  if (HB_UNLIKELY (type == SubstLookupSubTable::Extension))
+  if (unlikely (type == SubstLookupSubTable::Extension))
     return CastR<ExtensionSubst> (get_subtable()).is_reverse ();
   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 SubstLookup &l = gsub.get_lookup (lookup_index);
 
-  if (HB_UNLIKELY (context->nesting_level_left == 0))
+  if (unlikely (context->nesting_level_left == 0))
     return false;
 
-  if (HB_UNLIKELY (context_length < 1))
+  if (unlikely (context_length < 1))
     return false;
 
   return l.apply_once (layout_context, buffer, context_length, context->nesting_level_left - 1, apply_depth + 1);
diff --git a/src/hb-ot-layout-gsubgpos-private.hh b/src/hb-ot-layout-gsubgpos-private.hh
index 50126b4..2808601 100644
--- a/src/hb-ot-layout-gsubgpos-private.hh
+++ b/src/hb-ot-layout-gsubgpos-private.hh
@@ -100,19 +100,19 @@ static inline bool match_input (APPLY_ARG_DEF,
 {
   unsigned int i, j;
   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;
 
   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))
     {
-      if (HB_UNLIKELY (j + count - i == end))
+      if (unlikely (j + count - i == end))
 	return false;
       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;
   }
 
@@ -127,19 +127,19 @@ static inline bool match_backtrack (APPLY_ARG_DEF,
 				    match_func_t match_func,
 				    const char *match_data)
 {
-  if (HB_UNLIKELY (buffer->out_pos < count))
+  if (unlikely (buffer->out_pos < count))
     return false;
 
   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))
     {
-      if (HB_UNLIKELY (j + 1 == count - i))
+      if (unlikely (j + 1 == count - i))
 	return false;
       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;
   }
 
@@ -155,19 +155,19 @@ static inline bool match_lookahead (APPLY_ARG_DEF,
 {
   unsigned int i, j;
   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;
 
   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))
     {
-      if (HB_UNLIKELY (j + count - i == end))
+      if (unlikely (j + count - i == end))
 	return false;
       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;
   }
 
@@ -198,7 +198,7 @@ static inline bool apply_lookup (APPLY_ARG_DEF,
 				 apply_lookup_func_t apply_func)
 {
   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;
 
   /* 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))
     {
-      if (HB_UNLIKELY (buffer->in_pos == end))
+      if (unlikely (buffer->in_pos == end))
 	return true;
       /* No lookup applied for this index */
       _hb_buffer_next_glyph (buffer);
@@ -229,7 +229,7 @@ static inline bool apply_lookup (APPLY_ARG_DEF,
       lookupCount--;
       /* Err, this is wrong if the lookup jumped over some glyphs */
       i += buffer->in_pos - old_pos;
-      if (HB_UNLIKELY (buffer->in_pos == end))
+      if (unlikely (buffer->in_pos == end))
 	return true;
 
       if (!done)
@@ -345,7 +345,7 @@ struct ContextFormat1
   {
     TRACE_APPLY ();
     unsigned int index = (this+coverage) (IN_CURGLYPH ());
-    if (HB_LIKELY (index == NOT_COVERED))
+    if (likely (index == NOT_COVERED))
       return false;
 
     const RuleSet &rule_set = this+ruleSet[index];
@@ -382,7 +382,7 @@ struct ContextFormat2
   {
     TRACE_APPLY ();
     unsigned int index = (this+coverage) (IN_CURGLYPH ());
-    if (HB_LIKELY (index == NOT_COVERED))
+    if (likely (index == NOT_COVERED))
       return false;
 
     const ClassDef &class_def = this+classDef;
@@ -427,7 +427,7 @@ struct ContextFormat3
   {
     TRACE_APPLY ();
     unsigned int index = (this+coverage[0]) (IN_CURGLYPH ());
-    if (HB_LIKELY (index == NOT_COVERED))
+    if (likely (index == NOT_COVERED))
       return false;
 
     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)
 {
   /* First guess */
-  if (HB_UNLIKELY (buffer->out_pos < backtrackCount ||
+  if (unlikely (buffer->out_pos < backtrackCount ||
 		   buffer->in_pos + inputCount + lookaheadCount > buffer->in_length ||
 		   inputCount + lookaheadCount > context_length))
     return false;
@@ -629,7 +629,7 @@ struct ChainContextFormat1
   {
     TRACE_APPLY ();
     unsigned int index = (this+coverage) (IN_CURGLYPH ());
-    if (HB_LIKELY (index == NOT_COVERED))
+    if (likely (index == NOT_COVERED))
       return false;
 
     const ChainRuleSet &rule_set = this+ruleSet[index];
@@ -665,7 +665,7 @@ struct ChainContextFormat2
   {
     TRACE_APPLY ();
     unsigned int index = (this+coverage) (IN_CURGLYPH ());
-    if (HB_LIKELY (index == NOT_COVERED))
+    if (likely (index == NOT_COVERED))
       return false;
 
     const ClassDef &backtrack_class_def = this+backtrackClassDef;
@@ -728,7 +728,7 @@ struct ChainContextFormat3
     const OffsetArrayOf<Coverage> &input = StructAfter<OffsetArrayOf<Coverage> > (backtrack);
 
     unsigned int index = (this+input[0]) (IN_CURGLYPH ());
-    if (HB_LIKELY (index == NOT_COVERED))
+    if (likely (index == NOT_COVERED))
       return false;
 
     const OffsetArrayOf<Coverage> &lookahead = StructAfter<OffsetArrayOf<Coverage> > (input);
@@ -912,7 +912,7 @@ struct GSUBGPOS
   inline bool sanitize (SANITIZE_ARG_DEF) {
     TRACE_SANITIZE ();
     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);
   }
 
diff --git a/src/hb-ot-layout.cc b/src/hb-ot-layout.cc
index a450046..04cc982 100644
--- a/src/hb-ot-layout.cc
+++ b/src/hb-ot-layout.cc
@@ -75,19 +75,19 @@ _hb_ot_layout_fini (hb_face_t *face)
 static const GDEF&
 _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&
 _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&
 _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;
   unsigned int len = layout->new_gdef.len;
 
-  if (HB_UNLIKELY (glyph > 65535))
+  if (unlikely (glyph > 65535))
     return;
 
   /* XXX this is not threadsafe */
@@ -235,7 +235,7 @@ _hb_ot_layout_set_glyph_class (hb_face_t                  *face,
       new_len = 65536;
     new_klasses = (unsigned char *) realloc (layout->new_gdef.klasses, new_len * sizeof (unsigned char));
 
-    if (HB_UNLIKELY (!new_klasses))
+    if (unlikely (!new_klasses))
       return;
 
     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;
 
-  if (HB_UNLIKELY (!count || !glyphs || !klasses))
+  if (unlikely (!count || !glyphs || !klasses))
     return;
 
   if (layout->new_gdef.len == 0) {
diff --git a/src/hb-ot-tag.c b/src/hb-ot-tag.c
index 8b88eb3..fc4889b 100644
--- a/src/hb-ot-tag.c
+++ b/src/hb-ot-tag.c
@@ -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};
 
-  if (HB_UNLIKELY ((unsigned int) script >= ARRAY_LENGTH (ot_scripts)))
+  if (unlikely ((unsigned int) script >= ARRAY_LENGTH (ot_scripts)))
     return def_tag;
 
   return ot_scripts[script];
diff --git a/src/hb-private.h b/src/hb-private.h
index 1ee98c7..3f9ec9d 100644
--- a/src/hb-private.h
+++ b/src/hb-private.h
@@ -104,11 +104,11 @@
 	_hb_boolean_var_ = 0; \
      _hb_boolean_var_; \
   })
-#define HB_LIKELY(expr) (__builtin_expect (_HB_BOOLEAN_EXPR(expr), 1))
-#define HB_UNLIKELY(expr) (__builtin_expect (_HB_BOOLEAN_EXPR(expr), 0))
+#define likely(expr) (__builtin_expect (_HB_BOOLEAN_EXPR(expr), 1))
+#define unlikely(expr) (__builtin_expect (_HB_BOOLEAN_EXPR(expr), 0))
 #else
-#define HB_LIKELY(expr) (expr)
-#define HB_UNLIKELY(expr) (expr)
+#define likely(expr) (expr)
+#define unlikely(expr) (expr)
 #endif
 
 #ifndef __GNUC__
diff --git a/src/hb-shape.c b/src/hb-shape.c
index 89c0117..6818891 100644
--- a/src/hb-shape.c
+++ b/src/hb-shape.c
@@ -38,9 +38,9 @@
 static inline hb_bool_t
 is_variation_selector (hb_codepoint_t unicode)
 {
-  return HB_UNLIKELY ((unicode >=  0x180B && unicode <=  0x180D) || /* MONGOLIAN FREE VARIATION SELECTOR ONE..THREE */
-		      (unicode >=  0xFE00 && unicode <=  0xFE0F) || /* VARIATION SELECTOR-1..16 */
-		      (unicode >= 0xE0100 && unicode <= 0xE01EF));  /* VARIATION SELECTOR-17..256 */
+  return unlikely ((unicode >=  0x180B && unicode <=  0x180D) || /* MONGOLIAN FREE VARIATION SELECTOR ONE..THREE */
+		   (unicode >=  0xFE00 && unicode <=  0xFE0F) || /* VARIATION SELECTOR-1..16 */
+		   (unicode >= 0xE0100 && unicode <= 0xE01EF));  /* VARIATION SELECTOR-17..256 */
 }
 
 static void
@@ -95,11 +95,11 @@ hb_map_glyphs (hb_font_t    *font,
 {
   unsigned int count;
 
-  if (HB_UNLIKELY (!buffer->in_length))
+  if (unlikely (!buffer->in_length))
     return;
   count = buffer->in_length - 1;
   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());
       buffer->in_pos++;
     } else {
diff --git a/src/hb-unicode.c b/src/hb-unicode.c
index b75fe7e..fce79e6 100644
--- a/src/hb-unicode.c
+++ b/src/hb-unicode.c
@@ -294,7 +294,7 @@ const hb_direction_t horiz_dir[] =
 HB_INTERNAL hb_direction_t
 _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 horiz_dir[script];
commit fa3b3d58443a7c22eca3f86243993ba2d4bd9f4a
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Mon May 3 22:47:22 2010 -0400

    Mark a couple functions as inline

diff --git a/src/hb-open-type-private.hh b/src/hb-open-type-private.hh
index 508e670..75bd23d 100644
--- a/src/hb-open-type-private.hh
+++ b/src/hb-open-type-private.hh
@@ -143,7 +143,7 @@ struct hb_sanitize_context_t
 };
 
 
-static HB_UNUSED void
+static inline void
 _hb_sanitize_init (hb_sanitize_context_t *context,
 		   hb_blob_t *blob)
 {
@@ -157,7 +157,7 @@ _hb_sanitize_init (hb_sanitize_context_t *context,
 	     blob, context->start, context->end, context->end - context->start);
 }
 
-static HB_UNUSED void
+static inline void
 _hb_sanitize_fini (hb_sanitize_context_t *context HB_UNUSED,
 		   hb_blob_t *blob)
 {
commit 6b84198f9d471defb6f55d44d4f5423df70b2a10
Merge: 631d10b... eaf29ed...
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Mon May 3 22:46:52 2010 -0400

    Merge remote branch 'jrmuizel/master'

commit eaf29edb8fa49390e5f48b78105dfd173aff445b
Author: Jeff Muizelaar <jmuizelaar at mozilla.com>
Date:   Mon May 3 22:27:56 2010 -0400

    HB_UNUSED is unneeded on static inline functions

diff --git a/src/hb-object-private.h b/src/hb-object-private.h
index 937b1df..2f5429f 100644
--- a/src/hb-object-private.h
+++ b/src/hb-object-private.h
@@ -62,7 +62,7 @@ typedef struct {
 #define HB_DEBUG_OBJECT HB_DEBUG+0
 #endif
 
-static HB_UNUSED inline hb_bool_t /* always returns TRUE */
+static inline hb_bool_t /* always returns TRUE */
 _hb_object_debug_out (const void *obj,
 		      hb_reference_count_t *ref_count,
 		      const char *function)
diff --git a/src/hb-open-type-private.hh b/src/hb-open-type-private.hh
index bbd88a7..d4c2fd5 100644
--- a/src/hb-open-type-private.hh
+++ b/src/hb-open-type-private.hh
@@ -171,7 +171,7 @@ _hb_sanitize_fini (hb_sanitize_context_t *context HB_UNUSED,
   hb_blob_unlock (blob);
 }
 
-static HB_UNUSED inline bool
+static inline bool
 _hb_sanitize_check (SANITIZE_ARG_DEF,
 		    const char *base,
 		    unsigned int len)
@@ -191,7 +191,7 @@ _hb_sanitize_check (SANITIZE_ARG_DEF,
   return ret;
 }
 
-static HB_UNUSED inline bool
+static inline bool
 _hb_sanitize_array (SANITIZE_ARG_DEF,
 		    const char *base,
 		    unsigned int record_size,
@@ -211,7 +211,7 @@ _hb_sanitize_array (SANITIZE_ARG_DEF,
   return HB_LIKELY (!overflows) && _hb_sanitize_check (SANITIZE_ARG, base, record_size * len);
 }
 
-static HB_UNUSED inline bool
+static inline bool
 _hb_sanitize_edit (SANITIZE_ARG_DEF,
 		   const char *base HB_UNUSED,
 		   unsigned int len HB_UNUSED)
diff --git a/src/hb-private.h b/src/hb-private.h
index 9130b04..1ee98c7 100644
--- a/src/hb-private.h
+++ b/src/hb-private.h
@@ -161,7 +161,7 @@
  * in libgcc in case a target does not have one, which should be just as
  * good as the open-coded solution below, (which is "HACKMEM 169").
  */
-static HB_UNUSED inline unsigned int
+static inline unsigned int
 _hb_popcount32 (uint32_t mask)
 {
 #if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
@@ -240,7 +240,7 @@ typedef int hb_mutex_t;
 #define HB_DEBUG 0
 #endif
 
-static HB_UNUSED inline hb_bool_t /* always returns TRUE */
+static inline hb_bool_t /* always returns TRUE */
 _hb_trace (const char *what,
 	   const char *function,
 	   const void *obj,
commit 4ce578ed369f1526c91deedcf9e72537b3e4328f
Author: Jeff Muizelaar <jmuizelaar at mozilla.com>
Date:   Mon May 3 15:03:53 2010 -0400

    Include the tags from the Apple specification for TrueType fonts

diff --git a/src/hb-open-file-private.hh b/src/hb-open-file-private.hh
index 83f6571..aa49df5 100644
--- a/src/hb-open-file-private.hh
+++ b/src/hb-open-file-private.hh
@@ -198,6 +198,8 @@ struct OpenTypeFontFile
   static const hb_tag_t CFFTag		= HB_TAG ('O','T','T','O');
   static const hb_tag_t TrueTypeTag	= HB_TAG ( 0 , 1 , 0 , 0 );
   static const hb_tag_t TTCTag		= HB_TAG ('t','t','c','f');
+  static const hb_tag_t TrueTag		= HB_TAG ('t','r','u','e');
+  static const hb_tag_t Typ1Tag		= HB_TAG ('t','y','p','1');
 
   inline hb_tag_t get_tag (void) const { return u.tag; }
 
@@ -205,6 +207,8 @@ struct OpenTypeFontFile
   {
     switch (u.tag) {
     case CFFTag:	/* All the non-collection tags */
+    case TrueTag:
+    case Typ1Tag:
     case TrueTypeTag:	return 1;
     case TTCTag:	return u.ttcHeader->get_face_count ();
     default:		return 0;
@@ -217,6 +221,8 @@ struct OpenTypeFontFile
      * Apple dfont container is a container of SFNT's.  So each SFNT is a
      * non-TTC, but the index is more than zero. */
     case CFFTag:	/* All the non-collection tags */
+    case TrueTag:
+    case Typ1Tag:
     case TrueTypeTag:	return u.fontFace[0];
     case TTCTag:	return u.ttcHeader->get_face (i);
     default:		return Null(OpenTypeFontFace);
@@ -228,6 +234,8 @@ struct OpenTypeFontFile
     if (!SANITIZE (u.tag)) return false;
     switch (u.tag) {
     case CFFTag:	/* All the non-collection tags */
+    case TrueTag:
+    case Typ1Tag:
     case TrueTypeTag:	return u.fontFace->sanitize (SANITIZE_ARG);
     case TTCTag:	return u.ttcHeader->sanitize (SANITIZE_ARG);
     default:		return true;
commit 631d10b728d9e1a02c7dddf505d4fae5e244c6e8
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Sun May 2 21:14:21 2010 -0400

    Remove unused method

diff --git a/src/hb-open-file-private.hh b/src/hb-open-file-private.hh
index 83f6571..d8992c9 100644
--- a/src/hb-open-file-private.hh
+++ b/src/hb-open-file-private.hh
@@ -68,11 +68,6 @@ typedef struct OffsetTable
 
   inline unsigned int get_table_count (void) const
   { return numTables; }
-  inline const Tag& get_table_tag (unsigned int i) const
-  {
-    if (HB_UNLIKELY (i >= numTables)) return Null(Tag);
-    return tableDir[i].tag;
-  }
   inline const TableDirectory& get_table (unsigned int i) const
   {
     if (HB_UNLIKELY (i >= numTables)) return Null(TableDirectory);
commit f0abcd69408a3af65207cdf8847575ade4579bd4
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Sun May 2 18:14:25 2010 -0400

    Whitespace

diff --git a/src/hb-open-type-private.hh b/src/hb-open-type-private.hh
index bbd88a7..df8b088 100644
--- a/src/hb-open-type-private.hh
+++ b/src/hb-open-type-private.hh
@@ -86,12 +86,9 @@ inline Type& StructAfter(TObject &X)
 
 
 /*
- * Class features
+ * Null objects
  */
 
-
-/* Null objects */
-
 /* Global nul-content Null pool.  Enlarge as necessary. */
 static const void *_NullPool[32 / sizeof (void *)];
 
@@ -313,6 +310,8 @@ struct Sanitizer
 };
 
 
+
+
 /*
  *
  * The OpenType Font File: Data Types
@@ -437,7 +436,7 @@ ASSERT_SIZE (FixedVersion, 4);
 
 /*
  * Template subclasses of Offset and LongOffset that do the dereferencing.
- * Use: (this+memberName)
+ * Use: (base+offset)
  */
 
 template <typename OffsetType, typename Type>



More information about the HarfBuzz mailing list