Minor cleanup, add LIKELY and UNLIKELY annotations
diff --git a/src/hb-ot-layout-gdef-private.h b/src/hb-ot-layout-gdef-private.h
index 779b2b4..19df5f1 100644
--- a/src/hb-ot-layout-gdef-private.h
+++ b/src/hb-ot-layout-gdef-private.h
@@ -3,6 +3,15 @@
#include "hb-ot-layout-open-private.h"
+
+#define DEFINE_INDIRECT_GLYPH_ARRAY_LOOKUP(Type, name) \
+ inline const Type& name (uint16_t glyph_id) { \
+ const Coverage &c = get_coverage (); \
+ int c_index = c.get_coverage (glyph_id); \
+ return (*this)[c_index]; \
+ }
+
+
struct GlyphClassDef : ClassDef {
static const uint16_t BaseGlyph = 0x0001u;
static const uint16_t LigatureGlyph = 0x0002u;
@@ -27,19 +36,15 @@
DEFINE_NULL_ASSERT_SIZE (AttachPoint, 2);
struct AttachList {
-
- inline const AttachPoint* get_attach_points (uint16_t glyph_id) {
- const Coverage &c = get_coverage ();
- int c_index = c.get_coverage (glyph_id);
- return &(*this)[c_index];
- }
+ /* const AttachPoint& get_attach_points (uint16_t glyph_id); */
+ DEFINE_INDIRECT_GLYPH_ARRAY_LOOKUP (AttachPoint, get_attach_points);
private:
/* AttachPoint tables, in Coverage Index order */
DEFINE_OFFSET_ARRAY_TYPE (AttachPoint, attachPoint, glyphCount);
DEFINE_ACCESSOR (Coverage, get_coverage, coverage);
- private:
+ private:
Offset coverage; /* Offset to Coverage table -- from
* beginning of AttachList table */
USHORT glyphCount; /* Number of glyphs with attachment
@@ -54,22 +59,6 @@
* Ligature Caret Table
*/
-struct CaretValue;
-
-struct LigCaretList {
- /* TODO */
-
- private:
- Offset coverage; /* Offset to Coverage table--from
- * beginning of LigCaretList table */
- USHORT ligGlyphCount; /* Number of ligature glyphs */
- Offset ligGlyph[]; /* Array of offsets to LigGlyph
- * tables--from beginning of
- * LigCaretList table--in Coverage
- * Index order */
-};
-DEFINE_NULL_ASSERT_SIZE (LigCaretList, 4);
-
struct CaretValueFormat1 {
inline int get_caret_value (int ppem) const {
@@ -80,7 +69,7 @@
USHORT caretValueFormat; /* Format identifier--format = 1 */
SHORT coordinate; /* X or Y value, in design units */
};
-DEFINE_NULL_ASSERT_SIZE (CaretValueFormat1, 4);
+ASSERT_SIZE (CaretValueFormat1, 4);
struct CaretValueFormat2 {
@@ -92,12 +81,12 @@
USHORT caretValueFormat; /* Format identifier--format = 2 */
USHORT caretValuePoint; /* Contour point index on glyph */
};
-DEFINE_NULL_ASSERT_SIZE (CaretValueFormat2, 4);
+ASSERT_SIZE (CaretValueFormat2, 4);
struct CaretValueFormat3 {
inline const Device& get_device (void) const {
- if (!deviceTable) return NullDevice;
+ if (HB_UNLIKELY (!deviceTable)) return NullDevice;
return *(const Device*)((const char*)this + deviceTable);
}
@@ -112,7 +101,7 @@
* value--from beginning of CaretValue
* table */
};
-DEFINE_NULL_ASSERT_SIZE (CaretValueFormat3, 6);
+ASSERT_SIZE (CaretValueFormat3, 6);
struct CaretValue {
DEFINE_NON_INSTANTIABLE(CaretValue);
@@ -162,6 +151,26 @@
};
DEFINE_NULL_ASSERT_SIZE (LigGlyph, 2);
+struct LigCaretList {
+ /* const LigGlyph& get_lig_glyph (uint16_t glyph_id); */
+ DEFINE_INDIRECT_GLYPH_ARRAY_LOOKUP (LigGlyph, get_lig_glyph);
+
+ private:
+ /* AttachPoint tables, in Coverage Index order */
+ DEFINE_OFFSET_ARRAY_TYPE (LigGlyph, ligGlyph, ligGlyphCount);
+ DEFINE_ACCESSOR (Coverage, get_coverage, coverage);
+
+ private:
+ Offset coverage; /* Offset to Coverage table--from
+ * beginning of LigCaretList table */
+ USHORT ligGlyphCount; /* Number of ligature glyphs */
+ Offset ligGlyph[]; /* Array of offsets to LigGlyph
+ * tables--from beginning of
+ * LigCaretList table--in Coverage
+ * Index order */
+};
+DEFINE_NULL_ASSERT_SIZE (LigCaretList, 4);
+
/*
* GDEF Header
*/