Remove unused valDup (#443)

Remove the unused value duplicate API from dict. It's unused in the codebase and introduces unnecessary overhead. 

---------

Signed-off-by: Eran Liberty <eran.liberty@gmail.com>
This commit is contained in:
Eran Liberty 2024-06-03 22:22:06 +03:00 committed by GitHub
parent b95e7c384f
commit 0700c441c6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
16 changed files with 8 additions and 46 deletions

View File

@ -144,7 +144,6 @@ static inline int defaultClientPort(void) {
dictType clusterNodesDictType = {
dictSdsHash, /* hash function */
NULL, /* key dup */
NULL, /* val dup */
dictSdsKeyCompare, /* key compare */
dictSdsDestructor, /* key destructor */
NULL, /* val destructor */
@ -157,7 +156,6 @@ dictType clusterNodesDictType = {
dictType clusterNodesBlackListDictType = {
dictSdsCaseHash, /* hash function */
NULL, /* key dup */
NULL, /* val dup */
dictSdsKeyCaseCompare, /* key compare */
dictSdsDestructor, /* key destructor */
NULL, /* val destructor */
@ -168,7 +166,6 @@ dictType clusterNodesBlackListDictType = {
dictType clusterSdsToListType = {
dictSdsHash, /* hash function */
NULL, /* key dup */
NULL, /* val dup */
dictSdsKeyCompare, /* key compare */
dictSdsDestructor, /* key destructor */
dictListDestructor, /* val destructor */

View File

@ -986,7 +986,6 @@ void rewriteConfigSentinelOption(struct rewriteConfigState *state);
dictType optionToLineDictType = {
dictSdsCaseHash, /* hash function */
NULL, /* key dup */
NULL, /* val dup */
dictSdsKeyCaseCompare, /* key compare */
dictSdsDestructor, /* key destructor */
dictListDestructor, /* val destructor */
@ -996,7 +995,6 @@ dictType optionToLineDictType = {
dictType optionSetDictType = {
dictSdsCaseHash, /* hash function */
NULL, /* key dup */
NULL, /* val dup */
dictSdsKeyCaseCompare, /* key compare */
dictSdsDestructor, /* key destructor */
NULL, /* val destructor */

View File

@ -48,6 +48,8 @@
#include "serverassert.h"
#include "monotonic.h"
#define UNUSED(V) ((void)V)
/* Using dictSetResizeEnabled() we make possible to disable
* resizing and rehashing of the hash table as needed. This is very important
* for us, as we use copy-on-write and don't want to move too much memory
@ -800,8 +802,9 @@ void dictSetKey(dict *d, dictEntry *de, void *key) {
}
void dictSetVal(dict *d, dictEntry *de, void *val) {
UNUSED(d);
assert(entryHasValue(de));
de->v.val = d->type->valDup ? d->type->valDup(d, val) : val;
de->v.val = val;
}
void dictSetSignedIntegerVal(dictEntry *de, int64_t val) {

View File

@ -54,7 +54,6 @@ typedef struct dictType {
/* Callbacks */
uint64_t (*hashFunction)(const void *key);
void *(*keyDup)(dict *d, const void *key);
void *(*valDup)(dict *d, const void *obj);
int (*keyCompare)(dict *d, const void *key1, const void *key2);
void (*keyDestructor)(dict *d, void *key);
void (*valDestructor)(dict *d, void *obj);

View File

@ -71,7 +71,6 @@ static uint64_t dictStrCaseHash(const void *key) {
dictType shaScriptObjectDictType = {
dictStrCaseHash, /* hash function */
NULL, /* key dup */
NULL, /* val dup */
dictSdsKeyCaseCompare, /* key compare */
dictSdsDestructor, /* key destructor */
dictLuaScriptDestructor, /* val destructor */

View File

@ -470,7 +470,6 @@ void rememberSlaveKeyWithExpire(serverDb *db, robj *key) {
static dictType dt = {
dictSdsHash, /* hash function */
NULL, /* key dup */
NULL, /* val dup */
dictSdsKeyCompare, /* key compare */
dictSdsDestructor, /* key destructor */
NULL, /* val destructor */

View File

@ -65,7 +65,6 @@ typedef struct functionsLibMetaData {
dictType engineDictType = {
dictSdsCaseHash, /* hash function */
dictSdsDup, /* key dup */
NULL, /* val dup */
dictSdsKeyCaseCompare, /* key compare */
dictSdsDestructor, /* key destructor */
NULL, /* val destructor */
@ -75,7 +74,6 @@ dictType engineDictType = {
dictType functionDictType = {
dictSdsCaseHash, /* hash function */
dictSdsDup, /* key dup */
NULL, /* val dup */
dictSdsKeyCaseCompare, /* key compare */
dictSdsDestructor, /* key destructor */
NULL, /* val destructor */
@ -85,7 +83,6 @@ dictType functionDictType = {
dictType engineStatsDictType = {
dictSdsCaseHash, /* hash function */
dictSdsDup, /* key dup */
NULL, /* val dup */
dictSdsKeyCaseCompare, /* key compare */
dictSdsDestructor, /* key destructor */
engineStatsDispose, /* val destructor */
@ -95,7 +92,6 @@ dictType engineStatsDictType = {
dictType libraryFunctionDictType = {
dictSdsHash, /* hash function */
dictSdsDup, /* key dup */
NULL, /* val dup */
dictSdsKeyCompare, /* key compare */
dictSdsDestructor, /* key destructor */
engineFunctionDispose, /* val destructor */
@ -105,7 +101,6 @@ dictType libraryFunctionDictType = {
dictType librariesDictType = {
dictSdsHash, /* hash function */
dictSdsDup, /* key dup */
NULL, /* val dup */
dictSdsKeyCompare, /* key compare */
dictSdsDestructor, /* key destructor */
engineLibraryDispose, /* val destructor */

View File

@ -794,8 +794,9 @@ void kvstoreDictSetKey(kvstore *kvs, int didx, dictEntry *de, void *key) {
}
void kvstoreDictSetVal(kvstore *kvs, int didx, dictEntry *de, void *val) {
dict *d = kvstoreGetDict(kvs, didx);
dictSetVal(d, de, val);
UNUSED(kvs);
UNUSED(didx);
dictSetVal(NULL, de, val);
}
dictEntry *

View File

@ -51,7 +51,6 @@ void dictVanillaFree(dict *d, void *val);
dictType latencyTimeSeriesDictType = {
dictStringHash, /* hash function */
NULL, /* key dup */
NULL, /* val dup */
dictStringKeyCompare, /* key compare */
dictVanillaFree, /* key destructor */
dictVanillaFree, /* val destructor */

View File

@ -11780,7 +11780,6 @@ int dictCStringKeyCompare(dict *d, const void *key1, const void *key2) {
dictType moduleAPIDictType = {
dictCStringKeyHash, /* hash function */
NULL, /* key dup */
NULL, /* val dup */
dictCStringKeyCompare, /* key compare */
NULL, /* key destructor */
NULL, /* val destructor */
@ -11811,7 +11810,6 @@ void moduleInitModulesSystemLast(void) {
dictType sdsKeyValueHashDictType = {
dictSdsCaseHash, /* hash function */
NULL, /* key dup */
NULL, /* val dup */
dictSdsKeyCaseCompare, /* key compare */
dictSdsDestructor, /* key destructor */
dictSdsDestructor, /* val destructor */

View File

@ -430,7 +430,6 @@ void dictInstancesValDestructor(dict *d, void *obj) {
dictType instancesDictType = {
dictSdsHash, /* hash function */
NULL, /* key dup */
NULL, /* val dup */
dictSdsKeyCompare, /* key compare */
NULL, /* key destructor */
dictInstancesValDestructor, /* val destructor */
@ -444,7 +443,6 @@ dictType instancesDictType = {
dictType leaderVotesDictType = {
dictSdsHash, /* hash function */
NULL, /* key dup */
NULL, /* val dup */
dictSdsKeyCompare, /* key compare */
NULL, /* key destructor */
NULL, /* val destructor */
@ -455,7 +453,6 @@ dictType leaderVotesDictType = {
dictType renamedCommandsDictType = {
dictSdsCaseHash, /* hash function */
NULL, /* key dup */
NULL, /* val dup */
dictSdsKeyCaseCompare, /* key compare */
dictSdsDestructor, /* key destructor */
dictSdsDestructor, /* val destructor */

View File

@ -424,7 +424,6 @@ int dictResizeAllowed(size_t moreMem, double usedRatio) {
dictType objectKeyPointerValueDictType = {
dictEncObjHash, /* hash function */
NULL, /* key dup */
NULL, /* val dup */
dictEncObjKeyCompare, /* key compare */
dictObjectDestructor, /* key destructor */
NULL, /* val destructor */
@ -436,7 +435,6 @@ dictType objectKeyPointerValueDictType = {
dictType objectKeyHeapPointerValueDictType = {
dictEncObjHash, /* hash function */
NULL, /* key dup */
NULL, /* val dup */
dictEncObjKeyCompare, /* key compare */
dictObjectDestructor, /* key destructor */
dictVanillaFree, /* val destructor */
@ -447,7 +445,6 @@ dictType objectKeyHeapPointerValueDictType = {
dictType setDictType = {
dictSdsHash, /* hash function */
NULL, /* key dup */
NULL, /* val dup */
dictSdsKeyCompare, /* key compare */
dictSdsDestructor, /* key destructor */
NULL, /* val destructor */
@ -460,7 +457,6 @@ dictType setDictType = {
dictType zsetDictType = {
dictSdsHash, /* hash function */
NULL, /* key dup */
NULL, /* val dup */
dictSdsKeyCompare, /* key compare */
NULL, /* Note: SDS string shared & freed by skiplist */
NULL, /* val destructor */
@ -471,7 +467,6 @@ dictType zsetDictType = {
dictType dbDictType = {
dictSdsHash, /* hash function */
NULL, /* key dup */
NULL, /* val dup */
dictSdsKeyCompare, /* key compare */
dictSdsDestructor, /* key destructor */
dictObjectDestructor, /* val destructor */
@ -482,7 +477,6 @@ dictType dbDictType = {
dictType dbExpiresDictType = {
dictSdsHash, /* hash function */
NULL, /* key dup */
NULL, /* val dup */
dictSdsKeyCompare, /* key compare */
NULL, /* key destructor */
NULL, /* val destructor */
@ -493,7 +487,6 @@ dictType dbExpiresDictType = {
dictType commandTableDictType = {
dictSdsCaseHash, /* hash function */
NULL, /* key dup */
NULL, /* val dup */
dictSdsKeyCaseCompare, /* key compare */
dictSdsDestructor, /* key destructor */
NULL, /* val destructor */
@ -504,7 +497,6 @@ dictType commandTableDictType = {
dictType hashDictType = {
dictSdsHash, /* hash function */
NULL, /* key dup */
NULL, /* val dup */
dictSdsKeyCompare, /* key compare */
dictSdsDestructor, /* key destructor */
dictSdsDestructor, /* val destructor */
@ -515,7 +507,6 @@ dictType hashDictType = {
dictType sdsReplyDictType = {
dictSdsHash, /* hash function */
NULL, /* key dup */
NULL, /* val dup */
dictSdsKeyCompare, /* key compare */
NULL, /* key destructor */
NULL, /* val destructor */
@ -528,7 +519,6 @@ dictType sdsReplyDictType = {
dictType keylistDictType = {
dictObjHash, /* hash function */
NULL, /* key dup */
NULL, /* val dup */
dictObjKeyCompare, /* key compare */
dictObjectDestructor, /* key destructor */
dictListDestructor, /* val destructor */
@ -540,7 +530,6 @@ dictType keylistDictType = {
dictType objToDictDictType = {
dictObjHash, /* hash function */
NULL, /* key dup */
NULL, /* val dup */
dictObjKeyCompare, /* key compare */
dictObjectDestructor, /* key destructor */
dictDictDestructor, /* val destructor */
@ -552,7 +541,6 @@ dictType objToDictDictType = {
dictType modulesDictType = {
dictSdsCaseHash, /* hash function */
NULL, /* key dup */
NULL, /* val dup */
dictSdsKeyCaseCompare, /* key compare */
dictSdsDestructor, /* key destructor */
NULL, /* val destructor */
@ -563,7 +551,6 @@ dictType modulesDictType = {
dictType migrateCacheDictType = {
dictSdsHash, /* hash function */
NULL, /* key dup */
NULL, /* val dup */
dictSdsKeyCompare, /* key compare */
dictSdsDestructor, /* key destructor */
NULL, /* val destructor */
@ -575,7 +562,6 @@ dictType migrateCacheDictType = {
dictType stringSetDictType = {
dictCStrCaseHash, /* hash function */
NULL, /* key dup */
NULL, /* val dup */
dictCStrKeyCaseCompare, /* key compare */
dictSdsDestructor, /* key destructor */
NULL, /* val destructor */
@ -587,7 +573,6 @@ dictType stringSetDictType = {
dictType externalStringType = {
dictCStrCaseHash, /* hash function */
NULL, /* key dup */
NULL, /* val dup */
dictCStrKeyCaseCompare, /* key compare */
NULL, /* key destructor */
NULL, /* val destructor */
@ -599,7 +584,6 @@ dictType externalStringType = {
dictType sdsHashDictType = {
dictSdsCaseHash, /* hash function */
NULL, /* key dup */
NULL, /* val dup */
dictSdsKeyCaseCompare, /* key compare */
dictSdsDestructor, /* key destructor */
dictVanillaFree, /* val destructor */
@ -610,7 +594,6 @@ dictType sdsHashDictType = {
dictType clientDictType = {
dictClientHash, /* hash function */
NULL, /* key dup */
NULL, /* val dup */
dictClientKeyCompare, /* key compare */
.no_value = 1 /* no values in this dict */
};

View File

@ -2527,7 +2527,6 @@ static void zdiff(zsetopsrc *src, long setnum, zset *dstzset, size_t *maxelelen,
dictType setAccumulatorDictType = {
dictSdsHash, /* hash function */
NULL, /* key dup */
NULL, /* val dup */
dictSdsKeyCompare, /* key compare */
NULL, /* key destructor */
NULL, /* val destructor */

View File

@ -10,7 +10,7 @@ void freeTestCallback(dict *d, void *val) {
zfree(val);
}
dictType KvstoreDictTestType = {hashTestCallback, NULL, NULL, NULL, freeTestCallback, NULL, NULL};
dictType KvstoreDictTestType = {hashTestCallback, NULL, NULL, freeTestCallback, NULL, NULL};
char *stringFromInt(int value) {
char buf[32];

View File

@ -1243,7 +1243,6 @@ static int fetchClusterSlotsConfiguration(client c) {
static dictType dtype = {
dictSdsHash, /* hash function */
NULL, /* key dup */
NULL, /* val dup */
dictSdsKeyCompare, /* key compare */
NULL, /* key destructor */
NULL, /* val destructor */

View File

@ -882,7 +882,6 @@ static void cliInitHelp(void) {
dictType groupsdt = {
dictSdsHash, /* hash function */
NULL, /* key dup */
NULL, /* val dup */
dictSdsKeyCompare, /* key compare */
dictSdsDestructor, /* key destructor */
NULL, /* val destructor */
@ -3544,7 +3543,6 @@ typedef struct clusterManagerLink {
static dictType clusterManagerDictType = {
dictSdsHash, /* hash function */
NULL, /* key dup */
NULL, /* val dup */
dictSdsKeyCompare, /* key compare */
NULL, /* key destructor */
dictSdsDestructor, /* val destructor */
@ -3554,7 +3552,6 @@ static dictType clusterManagerDictType = {
static dictType clusterManagerLinkDictType = {
dictSdsHash, /* hash function */
NULL, /* key dup */
NULL, /* val dup */
dictSdsKeyCompare, /* key compare */
dictSdsDestructor, /* key destructor */
dictListDestructor, /* val destructor */
@ -8628,7 +8625,6 @@ void type_free(dict *d, void *val) {
static dictType typeinfoDictType = {
dictSdsHash, /* hash function */
NULL, /* key dup */
NULL, /* val dup */
dictSdsKeyCompare, /* key compare */
NULL, /* key destructor (owned by the value)*/
type_free, /* val destructor */