diff --git a/src/hb-open-type.hh b/src/hb-open-type.hh index 61ee139db..94a5c0351 100644 --- a/src/hb-open-type.hh +++ b/src/hb-open-type.hh @@ -1802,7 +1802,7 @@ struct TupleValues { iter_t (const unsigned char *p_, unsigned len_) : p (p_), endp (p_ + len_) - { if (ensure_run ()) read_value (); } + { if (likely (ensure_run ())) read_value (); } private: const unsigned char *p; @@ -1811,10 +1811,14 @@ struct TupleValues signed run_count = 0; unsigned width = 0; + HB_ALWAYS_INLINE bool ensure_run () { if (likely (run_count > 0)) return true; - + return _ensure_run (); + } + bool _ensure_run () + { if (unlikely (p >= endp)) { run_count = 0; @@ -1904,10 +1908,15 @@ struct TupleValues signed run_count = 0; unsigned width = 0; + HB_ALWAYS_INLINE bool ensure_run () { - if (run_count > 0) return true; + if (likely (run_count > 0)) return true; + return _ensure_run (); + } + bool _ensure_run () + { if (unlikely (p >= end)) { run_count = 0; diff --git a/src/hb-ot-layout-common.hh b/src/hb-ot-layout-common.hh index dff402068..5c0533aad 100644 --- a/src/hb-ot-layout-common.hh +++ b/src/hb-ot-layout-common.hh @@ -2586,7 +2586,17 @@ struct hb_scalar_cache_t void clear () { auto *values = &static_values[0]; - for (unsigned i = 0; i < length; i++) + unsigned i = 0; +#ifndef HB_OPTIMIZE_SIZE + for (; i + 3 < length; i += 4) + { + values[i + 0] = INVALID; + values[i + 1] = INVALID; + values[i + 2] = INVALID; + values[i + 3] = INVALID; + } +#endif + for (; i < length; i++) values[i] = INVALID; }