[HarfBuzz] harfbuzz-ng: Branch 'master' - 6 commits
Behdad Esfahbod
behdad at kemper.freedesktop.org
Mon May 10 21:04:20 PDT 2010
src/hb-open-file-private.hh | 4 ++--
src/hb-open-type-private.hh | 24 ++++++++++++------------
src/hb-ot-layout-common-private.hh | 2 +-
src/hb-ot-layout-gpos-private.hh | 9 ++++-----
src/hb-ot-layout-gsub-private.hh | 1 -
src/hb-private.h | 10 +---------
6 files changed, 20 insertions(+), 30 deletions(-)
New commits:
commit 494d28ad988e505c1c45cc35a7ec6b880cfec5fc
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Mon May 10 23:50:07 2010 -0400
Simplify likely() implementation
Shrinks .text by 1%!
diff --git a/src/hb-private.h b/src/hb-private.h
index 8a323de..866ee59 100644
--- a/src/hb-private.h
+++ b/src/hb-private.h
@@ -85,15 +85,7 @@
#if defined(__GNUC__) && (__GNUC__ > 2) && defined(__OPTIMIZE__)
-#define _HB_BOOLEAN_EXPR(expr) \
- __extension__ ({ \
- int _hb_boolean_var_; \
- if (expr) \
- _hb_boolean_var_ = 1; \
- else \
- _hb_boolean_var_ = 0; \
- _hb_boolean_var_; \
- })
+#define _HB_BOOLEAN_EXPR(expr) ((expr) ? 1 : 0)
#define likely(expr) (__builtin_expect (_HB_BOOLEAN_EXPR(expr), 1))
#define unlikely(expr) (__builtin_expect (_HB_BOOLEAN_EXPR(expr), 0))
#else
commit 75651b20871047d3ec17f4221794b8ef5d60e14b
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Mon May 10 23:44:51 2010 -0400
Fix warnings
diff --git a/src/hb-open-type-private.hh b/src/hb-open-type-private.hh
index 52afd6b..adbd4c7 100644
--- a/src/hb-open-type-private.hh
+++ b/src/hb-open-type-private.hh
@@ -154,7 +154,7 @@ struct hb_trace_t {
};
template <> /* Optimize when tracing is disabled */
struct hb_trace_t<0> {
- explicit hb_trace_t (unsigned int *pdepth, const char *what, const char *function, const void *obj) {}
+ explicit hb_trace_t (unsigned int *pdepth HB_UNUSED, const char *what HB_UNUSED, const char *function HB_UNUSED, const void *obj HB_UNUSED) {}
};
commit 4c20d8c057738b66150a88472714690e137884f8
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Mon May 10 23:27:54 2010 -0400
Sprinkle a few strategic likely()'s
Shrinks the code size by some 2% even.
diff --git a/src/hb-open-file-private.hh b/src/hb-open-file-private.hh
index 6d17db7..c56ce8f 100644
--- a/src/hb-open-file-private.hh
+++ b/src/hb-open-file-private.hh
@@ -168,7 +168,7 @@ struct TTCHeader
inline bool sanitize (hb_sanitize_context_t *context) {
TRACE_SANITIZE ();
- if (!u.header.version.sanitize (context)) return false;
+ if (unlikely (!u.header.version.sanitize (context))) return false;
switch (u.header.version) {
case 2: /* version 2 is compatible with version 1 */
case 1: return u.version1.sanitize (context);
@@ -230,7 +230,7 @@ struct OpenTypeFontFile
inline bool sanitize (hb_sanitize_context_t *context) {
TRACE_SANITIZE ();
- if (!u.tag.sanitize (context)) return false;
+ if (unlikely (!u.tag.sanitize (context))) return false;
switch (u.tag) {
case CFFTag: /* All the non-collection tags */
case TrueTag:
diff --git a/src/hb-open-type-private.hh b/src/hb-open-type-private.hh
index 5afccbf..52afd6b 100644
--- a/src/hb-open-type-private.hh
+++ b/src/hb-open-type-private.hh
@@ -386,7 +386,7 @@ struct IntType
inline bool operator != (const IntType<Type> &o) const { return v != o.v; }
inline bool sanitize (hb_sanitize_context_t *context) {
TRACE_SANITIZE ();
- return context->check_struct (this);
+ return likely (context->check_struct (this));
}
protected:
BEInt<Type, sizeof (Type)> v;
@@ -482,7 +482,7 @@ struct GenericOffsetTo : OffsetType
inline bool sanitize (hb_sanitize_context_t *context, void *base) {
TRACE_SANITIZE ();
- if (!context->check_struct (this)) return false;
+ if (unlikely (!context->check_struct (this))) return false;
unsigned int offset = *this;
if (unlikely (!offset)) return true;
Type &obj = StructAtOffset<Type> (base, offset);
@@ -491,7 +491,7 @@ struct GenericOffsetTo : OffsetType
template <typename T>
inline bool sanitize (hb_sanitize_context_t *context, void *base, T user_data) {
TRACE_SANITIZE ();
- if (!context->check_struct (this)) return false;
+ if (unlikely (!context->check_struct (this))) return false;
unsigned int offset = *this;
if (unlikely (!offset)) return true;
Type &obj = StructAtOffset<Type> (base, offset);
@@ -547,7 +547,7 @@ struct GenericArrayOf
inline bool sanitize (hb_sanitize_context_t *context) {
TRACE_SANITIZE ();
- if (!likely (sanitize_shallow (context))) return false;
+ if (unlikely (!sanitize_shallow (context))) return false;
/* Note: for structs that do not reference other structs,
* we do not need to call their sanitize() as we already did
* a bound check on the aggregate array size, hence the return.
@@ -564,20 +564,20 @@ struct GenericArrayOf
}
inline bool sanitize (hb_sanitize_context_t *context, void *base) {
TRACE_SANITIZE ();
- if (!likely (sanitize_shallow (context))) return false;
+ if (unlikely (!sanitize_shallow (context))) return false;
unsigned int count = len;
for (unsigned int i = 0; i < count; i++)
- if (!array[i].sanitize (context, base))
+ if (unlikely (!array[i].sanitize (context, base)))
return false;
return true;
}
template <typename T>
inline bool sanitize (hb_sanitize_context_t *context, void *base, T user_data) {
TRACE_SANITIZE ();
- if (!likely (sanitize_shallow (context))) return false;
+ if (unlikely (!sanitize_shallow (context))) return false;
unsigned int count = len;
for (unsigned int i = 0; i < count; i++)
- if (!array[i].sanitize (context, base, user_data))
+ if (unlikely (!array[i].sanitize (context, base, user_data)))
return false;
return true;
}
@@ -658,7 +658,7 @@ struct HeadlessArrayOf
inline bool sanitize (hb_sanitize_context_t *context) {
TRACE_SANITIZE ();
- if (!likely (sanitize_shallow (context))) return false;
+ if (unlikely (!sanitize_shallow (context))) return false;
/* Note: for structs that do not reference other structs,
* we do not need to call their sanitize() as we already did
* a bound check on the aggregate array size, hence the return.
@@ -670,7 +670,7 @@ struct HeadlessArrayOf
unsigned int count = len ? len - 1 : 0;
Type *a = array;
for (unsigned int i = 0; i < count; i++)
- if (!a[i].sanitize (context))
+ if (unlikely (!a[i].sanitize (context)))
return false;
return true;
}
commit 69cb28bc13d236a01acf40da62e345c7e83ccba7
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Mon May 10 23:13:08 2010 -0400
Remove a few likely()'s
diff --git a/src/hb-ot-layout-common-private.hh b/src/hb-ot-layout-common-private.hh
index fb07161..75cbc64 100644
--- a/src/hb-ot-layout-common-private.hh
+++ b/src/hb-ot-layout-common-private.hh
@@ -284,7 +284,7 @@ struct Lookup
TRACE_SANITIZE ();
/* Real sanitize of the subtables is done by GSUB/GPOS/... */
if (!(context->check_struct (this)
- && likely (subTable.sanitize (context)))) return false;
+ && subTable.sanitize (context))) return false;
if (unlikely (lookupFlag & LookupFlag::UseMarkFilteringSet))
{
USHORT &markFilteringSet = StructAfter<USHORT> (subTable);
diff --git a/src/hb-ot-layout-gpos-private.hh b/src/hb-ot-layout-gpos-private.hh
index f028245..04b156f 100644
--- a/src/hb-ot-layout-gpos-private.hh
+++ b/src/hb-ot-layout-gpos-private.hh
@@ -633,7 +633,7 @@ struct PairPosFormat1
if (!(context->check_struct (this)
&& coverage.sanitize (context, this)
- && likely (pairSet.sanitize (context, this, len1 + len2)))) return false;
+ && pairSet.sanitize (context, this, len1 + len2))) return false;
if (!(valueFormat1.has_device () || valueFormat2.has_device ())) return true;
@@ -1092,7 +1092,7 @@ struct MarkBasePosFormat1
&& markCoverage.sanitize (context, this)
&& baseCoverage.sanitize (context, this)
&& markArray.sanitize (context, this)
- && likely (baseArray.sanitize (context, this, (unsigned int) classCount));
+ && baseArray.sanitize (context, this, (unsigned int) classCount);
}
private:
@@ -1215,7 +1215,7 @@ struct MarkLigPosFormat1
&& markCoverage.sanitize (context, this)
&& ligatureCoverage.sanitize (context, this)
&& markArray.sanitize (context, this)
- && likely (ligatureArray.sanitize (context, this, (unsigned int) classCount));
+ && ligatureArray.sanitize (context, this, (unsigned int) classCount);
}
private:
@@ -1319,7 +1319,7 @@ struct MarkMarkPosFormat1
&& mark1Coverage.sanitize (context, this)
&& mark2Coverage.sanitize (context, this)
&& mark1Array.sanitize (context, this)
- && likely (mark2Array.sanitize (context, this, (unsigned int) classCount));
+ && mark2Array.sanitize (context, this, (unsigned int) classCount);
}
private:
commit 24552ecf92982fe561dc47d5102fcf1a7b337c70
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Mon May 10 23:08:41 2010 -0400
Remove excess sub_format sanitize
diff --git a/src/hb-ot-layout-gpos-private.hh b/src/hb-ot-layout-gpos-private.hh
index c814893..f028245 100644
--- a/src/hb-ot-layout-gpos-private.hh
+++ b/src/hb-ot-layout-gpos-private.hh
@@ -1460,7 +1460,6 @@ struct PosLookupSubTable
inline bool sanitize (hb_sanitize_context_t *context, unsigned int lookup_type) {
TRACE_SANITIZE ();
- if (!u.sub_format.sanitize (context)) return false;
switch (lookup_type) {
case Single: return u.single.sanitize (context);
case Pair: return u.pair.sanitize (context);
diff --git a/src/hb-ot-layout-gsub-private.hh b/src/hb-ot-layout-gsub-private.hh
index 494e2de..849a20c 100644
--- a/src/hb-ot-layout-gsub-private.hh
+++ b/src/hb-ot-layout-gsub-private.hh
@@ -732,7 +732,6 @@ struct SubstLookupSubTable
inline bool sanitize (hb_sanitize_context_t *context, unsigned int lookup_type) {
TRACE_SANITIZE ();
- if (!u.sub_format.sanitize (context)) return false;
switch (lookup_type) {
case Single: return u.single.sanitize (context);
case Multiple: return u.multiple.sanitize (context);
commit f7adc5e9be352ac31ad3ab847abb6fceb239aa12
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Mon May 10 22:41:50 2010 -0400
Shrink NullPool now that we have accurate size tracking
diff --git a/src/hb-open-type-private.hh b/src/hb-open-type-private.hh
index 71fb44e..5afccbf 100644
--- a/src/hb-open-type-private.hh
+++ b/src/hb-open-type-private.hh
@@ -113,7 +113,7 @@ inline Type& StructAfter(TObject &X)
*/
/* Global nul-content Null pool. Enlarge as necessary. */
-static const void *_NullPool[32 / sizeof (void *)];
+static const void *_NullPool[16 / sizeof (void *)];
/* Generic nul-content Null objects. */
template <typename Type>
More information about the HarfBuzz
mailing list