[VarStore] Pepper cache with likely()

This commit is contained in:
Behdad Esfahbod 2022-05-20 17:32:56 -06:00
parent cf8f00e354
commit da38312e42
1 changed files with 3 additions and 5 deletions

View File

@ -2618,7 +2618,7 @@ struct VarRegionList
if (cache) if (cache)
{ {
cached = &(cache[region_index]); cached = &(cache[region_index]);
if (*cached != REGION_CACHE_ITEM_CACHE_INVALID) if (likely (*cached != REGION_CACHE_ITEM_CACHE_INVALID))
return *cached; return *cached;
} }
@ -2632,14 +2632,14 @@ struct VarRegionList
float factor = axes[i].evaluate (coord); float factor = axes[i].evaluate (coord);
if (factor == 0.f) if (factor == 0.f)
{ {
if (cached) if (cache)
*cached = 0.; *cached = 0.;
return 0.; return 0.;
} }
v *= factor; v *= factor;
} }
if (cached) if (cache)
*cached = v; *cached = v;
return v; return v;
} }
@ -2877,11 +2877,9 @@ 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] = REGION_CACHE_ITEM_CACHE_INVALID; cache[i] = REGION_CACHE_ITEM_CACHE_INVALID;
return cache; return cache;
} }