[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.
This commit is contained in:
Behdad Esfahbod 2022-05-20 17:14:10 -06:00
parent 5336ba70f6
commit cf8f00e354
1 changed files with 8 additions and 2 deletions

View File

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