mirror of
https://github.com/valkey-io/valkey.git
synced 2026-05-09 06:49:36 -04:00
fb655dbf5c
Replace the dict.c implementation with a header-only wrapper (dict.h) around the hashtable API. The dict types, iterators and API functions are now typedefs, macros and inline functions that delegate to hashtable. This unifies the hashtable implementations in the project and removes duplicated logic. Changes to dict: - Remove dict.c; dict.h is now the entire implementation - dict, dictType and dictIterator are direct aliases for the hashtable counterparts. - dictEntry is a struct allocated by dict wrapper functions to hold key and value. It doesn't have a next pointer anymore. - Fix key duplication for dictTypes that had keyDup callback by calling sdsdup() at call sites in functions.c - Remove unused functions, macros, includes and casts - Move some dict defrag logic to defrag.c - Remove obsolete dict unit tests (covered by test_hashtable.cpp) Changes to hashtable: - Change hashtable keyCompare convention to match dict: non-zero means keys are equal, so existing dict compare functions can be reused - Add const to hashtableMemUsage parameter Changes to server implementation: - Deduplicate common dict/hashtable callbacks in server.c - Change configured hash-seed to only apply to data hashtables. In particular, it must not modify the hash seed for dicts already initialized during startup for reading configs and similar. Changes to libvalkey: - Let libvalkey use its own dict implementation. --------- Signed-off-by: Viktor Söderqvist <viktor.soderqvist@est.tech>