[VarStore] Don't use NAN

Is faster.

With this, I'm seeing 25 to 28% speedup in glyph_h_advances benchmark
of benchmark-font for var/hb tests.
pull/3605/head
Behdad Esfahbod 3 years ago
parent 5336ba70f6
commit cf8f00e354
  1. 10
      src/hb-ot-layout-common.hh

@ -2601,6 +2601,8 @@ struct VarRegionAxis
DEFINE_SIZE_STATIC (6); DEFINE_SIZE_STATIC (6);
}; };
#define REGION_CACHE_ITEM_CACHE_INVALID 2.f
struct VarRegionList struct VarRegionList
{ {
using cache_t = float; using cache_t = float;
@ -2616,7 +2618,7 @@ struct VarRegionList
if (cache) if (cache)
{ {
cached = &(cache[region_index]); cached = &(cache[region_index]);
if (!std::isnan (*cached)) if (*cached != REGION_CACHE_ITEM_CACHE_INVALID)
return *cached; return *cached;
} }
@ -2875,8 +2877,10 @@ struct VariationStore
float *cache = (float *) hb_malloc (sizeof (float) * count); float *cache = (float *) hb_malloc (sizeof (float) * count);
if (unlikely (!cache)) return nullptr; if (unlikely (!cache)) return nullptr;
for (unsigned i = 0; i < count; i++) for (unsigned i = 0; i < count; i++)
cache[i] = NAN; cache[i] = REGION_CACHE_ITEM_CACHE_INVALID;
return cache; return cache;
} }
@ -3035,6 +3039,8 @@ struct VariationStore
DEFINE_SIZE_ARRAY_SIZED (8, dataSets); DEFINE_SIZE_ARRAY_SIZED (8, dataSets);
}; };
#undef REGION_CACHE_ITEM_CACHE_INVALID
/* /*
* Feature Variations * Feature Variations
*/ */

Loading…
Cancel
Save