diff options
author | Alexei Podtelezhnikov <apodtele@gmail.com> | 2023-05-09 06:49:37 -0400 |
---|---|---|
committer | Alexei Podtelezhnikov <apodtele@gmail.com> | 2023-05-09 06:49:37 -0400 |
commit | eb5b6261df49e8dea67e875f161a13eacc635863 (patch) | |
tree | c851810808027ca972b313bd619ec6ed731ab04e /src/cache/ftccache.h | |
parent | c3876354e5c0812ae5929f7e68849c2e611b720c (diff) | |
download | freetype2-eb5b6261df49e8dea67e875f161a13eacc635863.tar.gz |
[cache] Revise the hash table accounting.ftc_resize
Instead of counting entries relative to the middle of the hash table,
this switches to the absolute counter with the full index range mask.
As a result, some calculations become a bit simpler.
* src/cache/ftccache.h (FTC_NODE_TOP_FOR_HASH): Revised.
* src/cache/ftccache.c (ftc_get_top_node_for_hash): Ditto.
(ftc_cache_resize, ftc_cache_init, FTC_Cache_Clear,
FTC_Cache_RemoveFaceID): Updated accordingly.
Diffstat (limited to 'src/cache/ftccache.h')
-rw-r--r-- | src/cache/ftccache.h | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/cache/ftccache.h b/src/cache/ftccache.h index 23bcb6585..976d63e86 100644 --- a/src/cache/ftccache.h +++ b/src/cache/ftccache.h @@ -73,10 +73,10 @@ FT_BEGIN_HEADER #define FTC_NODE_PREV( x ) FTC_NODE( (x)->mru.prev ) #ifdef FTC_INLINE -#define FTC_NODE_TOP_FOR_HASH( cache, hash ) \ - ( ( cache )->buckets + \ - ( ( ( ( hash ) & ( cache )->mask ) < ( cache )->p ) \ - ? ( ( hash ) & ( ( cache )->mask * 2 + 1 ) ) \ +#define FTC_NODE_TOP_FOR_HASH( cache, hash ) \ + ( ( cache )->buckets + \ + ( ( ( ( hash ) & ( cache )->mask ) >= ( cache )->p ) \ + ? ( ( hash ) & ( ( cache )->mask >> 1 ) ) \ : ( ( hash ) & ( cache )->mask ) ) ) #else FT_LOCAL( FTC_Node* ) @@ -142,8 +142,8 @@ FT_BEGIN_HEADER /* each cache really implements a dynamic hash table to manage its nodes */ typedef struct FTC_CacheRec_ { - FT_UFast p; - FT_UFast mask; + FT_UFast p; /* hash table counter */ + FT_UFast mask; /* hash table index range */ FT_Long slack; FTC_Node* buckets; |