Skip to content

Commit

Permalink
Remove unused valDup
Browse files Browse the repository at this point in the history
  • Loading branch information
eliblight committed May 1, 2024
1 parent af1b0de commit 91a2462
Show file tree
Hide file tree
Showing 23 changed files with 25 additions and 85 deletions.
13 changes: 0 additions & 13 deletions deps/hiredis/async.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,18 +62,6 @@ static unsigned int callbackHash(const void *key) {
hi_sdslen((const hisds)key));
}

static void *callbackValDup(void *privdata, const void *src) {
((void) privdata);
redisCallback *dup;

dup = hi_malloc(sizeof(*dup));
if (dup == NULL)
return NULL;

memcpy(dup,src,sizeof(*dup));
return dup;
}

static int callbackKeyCompare(void *privdata, const void *key1, const void *key2) {
int l1, l2;
((void) privdata);
Expand All @@ -97,7 +85,6 @@ static void callbackValDestructor(void *privdata, void *val) {
static dictType callbackDict = {
callbackHash,
NULL,
callbackValDup,
callbackKeyCompare,
callbackKeyDestructor,
callbackValDestructor
Expand Down
6 changes: 1 addition & 5 deletions deps/hiredis/dict.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ typedef struct dictEntry {
typedef struct dictType {
unsigned int (*hashFunction)(const void *key);
void *(*keyDup)(void *privdata, const void *key);
void *(*valDup)(void *privdata, const void *obj);
int (*keyCompare)(void *privdata, const void *key1, const void *key2);
void (*keyDestructor)(void *privdata, void *key);
void (*valDestructor)(void *privdata, void *obj);
Expand Down Expand Up @@ -81,10 +80,7 @@ typedef struct dictIterator {
(ht)->type->valDestructor((ht)->privdata, (entry)->val)

#define dictSetHashVal(ht, entry, _val_) do { \
if ((ht)->type->valDup) \
entry->val = (ht)->type->valDup((ht)->privdata, _val_); \
else \
entry->val = (_val_); \
entry->val = (_val_); \
} while(0)

#define dictFreeEntryKey(ht, entry) \
Expand Down
4 changes: 2 additions & 2 deletions src/blocked.c
Original file line number Diff line number Diff line change
Expand Up @@ -389,13 +389,13 @@ void blockForKeys(client *c, int btype, robj **keys, int numkeys, mstime_t timeo
/* In case key[j] did not have blocking clients yet, we need to create a new list */
if (db_blocked_entry != NULL) {
l = listCreate();
dictSetVal(c->db->blocking_keys, db_blocked_entry, l);
dictSetVal(db_blocked_entry, l);
incrRefCount(keys[j]);
} else {
l = dictGetVal(db_blocked_existing_entry);
}
listAddNodeTail(l,c);
dictSetVal(c->bstate.keys,client_blocked_entry,listLast(l));
dictSetVal(client_blocked_entry,listLast(l));

/* We need to add the key to blocking_keys_unblock_on_nokey, if the client
* wants to be awakened if key is deleted (like XREADGROUP) */
Expand Down
3 changes: 0 additions & 3 deletions src/cluster_legacy.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,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 */
Expand All @@ -151,7 +150,6 @@ dictType clusterNodesDictType = {
dictType clusterNodesBlackListDictType = {
dictSdsCaseHash, /* hash function */
NULL, /* key dup */
NULL, /* val dup */
dictSdsKeyCaseCompare, /* key compare */
dictSdsDestructor, /* key destructor */
NULL, /* val destructor */
Expand All @@ -162,7 +160,6 @@ dictType clusterNodesBlackListDictType = {
dictType clusterSdsToListType = {
dictSdsHash, /* hash function */
NULL, /* key dup */
NULL, /* val dup */
dictSdsKeyCompare, /* key compare */
dictSdsDestructor, /* key destructor */
dictListDestructor, /* val destructor */
Expand Down
2 changes: 0 additions & 2 deletions src/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -1033,7 +1033,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 */
Expand All @@ -1043,7 +1042,6 @@ dictType optionToLineDictType = {
dictType optionSetDictType = {
dictSdsCaseHash, /* hash function */
NULL, /* key dup */
NULL, /* val dup */
dictSdsKeyCaseCompare, /* key compare */
dictSdsDestructor, /* key destructor */
NULL, /* val destructor */
Expand Down
8 changes: 4 additions & 4 deletions src/db.c
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ static void dbAddInternal(redisDb *db, robj *key, robj *val, int update_if_exist
serverAssertWithInfo(NULL, key, de != NULL);
kvstoreDictSetKey(db->keys, slot, de, sdsdup(key->ptr));
initObjectLRUOrLFU(val);
kvstoreDictSetVal(db->keys, slot, de, val);
kvstoreDictSetVal(de, val);
signalKeyAsReady(db, key, val->type);
notifyKeyspaceEvent(NOTIFY_NEW,"new",key,db->id);
}
Expand Down Expand Up @@ -256,7 +256,7 @@ int dbAddRDBLoad(redisDb *db, sds key, robj *val) {
dictEntry *de = kvstoreDictAddRaw(db->keys, slot, key, NULL);
if (de == NULL) return 0;
initObjectLRUOrLFU(val);
kvstoreDictSetVal(db->keys, slot, de, val);
kvstoreDictSetVal(de, val);
return 1;
}

Expand Down Expand Up @@ -294,7 +294,7 @@ static void dbSetValue(redisDb *db, robj *key, robj *val, int overwrite, dictEnt
/* Because of RM_StringDMA, old may be changed, so we need get old again */
old = dictGetVal(de);
}
kvstoreDictSetVal(db->keys, slot, de, val);
kvstoreDictSetVal(de, val);
if (server.lazyfree_lazy_server_del) {
freeObjAsync(key,old,db->id);
} else {
Expand Down Expand Up @@ -403,7 +403,7 @@ int dbGenericDelete(redisDb *db, robj *key, int async, int flags) {
if (async) {
/* Because of dbUnshareStringValue, the val in de may change. */
freeObjAsync(key, dictGetVal(de), db->id);
kvstoreDictSetVal(db->keys, slot, de, NULL);
kvstoreDictSetVal(de, NULL);
}
/* Deleting an entry from the expires dict will not free the sds of
* the key, because it is shared with the main dictionary. */
Expand Down
6 changes: 3 additions & 3 deletions src/defrag.c
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ void activeDefragZsetEntry(zset *zs, dictEntry *de) {
dictSetKey(zs->dict, de, newsds);
newscore = zslDefrag(zs->zsl, *(double*)dictGetVal(de), sdsele, newsds);
if (newscore) {
dictSetVal(zs->dict, de, newscore);
dictSetVal(de, newscore);
}
}

Expand Down Expand Up @@ -715,7 +715,7 @@ void defragKey(defragCtx *ctx, dictEntry *de) {
/* Try to defrag robj and / or string value. */
ob = dictGetVal(de);
if ((newob = activeDefragStringOb(ob))) {
kvstoreDictSetVal(db->keys, slot, de, newob);
kvstoreDictSetVal(de, newob);
ob = newob;
}

Expand Down Expand Up @@ -835,7 +835,7 @@ void defragPubsubScanCallback(void *privdata, const dictEntry *de) {

/* Try to defrag the dictionary of clients that is stored as the value part. */
if ((newclients = dictDefragTables(clients)))
kvstoreDictSetVal(pubsub_channels, ctx->slot, (dictEntry*)de, newclients);
kvstoreDictSetVal((dictEntry*)de, newclients);

server.stat_active_defrag_scanned++;
}
Expand Down
10 changes: 5 additions & 5 deletions src/dict.c
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ int dictAdd(dict *d, void *key, void *val)
dictEntry *entry = dictAddRaw(d,key,NULL);

if (!entry) return DICT_ERR;
if (!d->type->no_value) dictSetVal(d, entry, val);
if (!d->type->no_value) dictSetVal(entry, val);
return DICT_OK;
}

Expand Down Expand Up @@ -553,7 +553,7 @@ int dictReplace(dict *d, void *key, void *val)
* does not exists dictAdd will succeed. */
entry = dictAddRaw(d,key,&existing);
if (entry) {
dictSetVal(d, entry, val);
dictSetVal(entry, val);
return 1;
}

Expand All @@ -563,7 +563,7 @@ int dictReplace(dict *d, void *key, void *val)
* you want to increment (set), and then decrement (free), and not the
* reverse. */
void *oldval = dictGetVal(existing);
dictSetVal(d, existing, val);
dictSetVal(existing, val);
if (d->type->valDestructor)
d->type->valDestructor(d, oldval);
return 0;
Expand Down Expand Up @@ -820,9 +820,9 @@ void dictSetKey(dict *d, dictEntry* de, void *key) {
de->key = key;
}

void dictSetVal(dict *d, dictEntry *de, void *val) {
void dictSetVal(dictEntry *de, void *val) {
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) {
Expand Down
3 changes: 1 addition & 2 deletions src/dict.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -203,7 +202,7 @@ void *dictFetchValue(dict *d, const void *key);
int dictShrinkIfNeeded(dict *d);
int dictExpandIfNeeded(dict *d);
void dictSetKey(dict *d, dictEntry* de, void *key);
void dictSetVal(dict *d, dictEntry *de, void *val);
void dictSetVal(dictEntry *de, void *val);
void dictSetSignedIntegerVal(dictEntry *de, int64_t val);
void dictSetUnsignedIntegerVal(dictEntry *de, uint64_t val);
void dictSetDoubleVal(dictEntry *de, double val);
Expand Down
1 change: 0 additions & 1 deletion src/eval.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,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 */
Expand Down
1 change: 0 additions & 1 deletion src/expire.c
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,6 @@ void rememberSlaveKeyWithExpire(redisDb *db, robj *key) {
static dictType dt = {
dictSdsHash, /* hash function */
NULL, /* key dup */
NULL, /* val dup */
dictSdsKeyCompare, /* key compare */
dictSdsDestructor, /* key destructor */
NULL, /* val destructor */
Expand Down
9 changes: 2 additions & 7 deletions src/functions.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ typedef struct functionsLibMetaData {
dictType engineDictType = {
dictSdsCaseHash, /* hash function */
dictSdsDup, /* key dup */
NULL, /* val dup */
dictSdsKeyCaseCompare, /* key compare */
dictSdsDestructor, /* key destructor */
NULL, /* val destructor */
Expand All @@ -78,7 +77,6 @@ dictType engineDictType = {
dictType functionDictType = {
dictSdsCaseHash, /* hash function */
dictSdsDup, /* key dup */
NULL, /* val dup */
dictSdsKeyCaseCompare,/* key compare */
dictSdsDestructor, /* key destructor */
NULL, /* val destructor */
Expand All @@ -88,7 +86,6 @@ dictType functionDictType = {
dictType engineStatsDictType = {
dictSdsCaseHash, /* hash function */
dictSdsDup, /* key dup */
NULL, /* val dup */
dictSdsKeyCaseCompare,/* key compare */
dictSdsDestructor, /* key destructor */
engineStatsDispose, /* val destructor */
Expand All @@ -98,7 +95,6 @@ dictType engineStatsDictType = {
dictType libraryFunctionDictType = {
dictSdsHash, /* hash function */
dictSdsDup, /* key dup */
NULL, /* val dup */
dictSdsKeyCompare, /* key compare */
dictSdsDestructor, /* key destructor */
engineFunctionDispose,/* val destructor */
Expand All @@ -108,7 +104,6 @@ dictType libraryFunctionDictType = {
dictType librariesDictType = {
dictSdsHash, /* hash function */
dictSdsDup, /* key dup */
NULL, /* val dup */
dictSdsKeyCompare, /* key compare */
dictSdsDestructor, /* key destructor */
engineLibraryDispose, /* val destructor */
Expand Down Expand Up @@ -290,7 +285,7 @@ static void libraryUnlink(functionsLibCtx *lib_ctx, functionLibInfo* li) {
}
dictReleaseIterator(iter);
entry = dictUnlink(lib_ctx->libraries, li->name);
dictSetVal(lib_ctx->libraries, entry, NULL);
dictSetVal(entry, NULL);
dictFreeUnlinkedEntry(lib_ctx->libraries, entry);
lib_ctx->cache_memory -= libraryMallocSize(li);

Expand Down Expand Up @@ -373,7 +368,7 @@ static int libraryJoin(functionsLibCtx *functions_lib_ctx_dst, functionsLibCtx *
while ((entry = dictNext(iter))) {
functionLibInfo *li = dictGetVal(entry);
libraryLink(functions_lib_ctx_dst, li);
dictSetVal(functions_lib_ctx_src->libraries, entry, NULL);
dictSetVal(entry, NULL);
}
dictReleaseIterator(iter);
iter = NULL;
Expand Down
5 changes: 2 additions & 3 deletions src/kvstore.c
Original file line number Diff line number Diff line change
Expand Up @@ -835,9 +835,8 @@ void kvstoreDictSetKey(kvstore *kvs, int didx, dictEntry* de, void *key) {
dictSetKey(d, de, key);
}

void kvstoreDictSetVal(kvstore *kvs, int didx, dictEntry *de, void *val) {
dict *d = kvstoreGetDict(kvs, didx);
dictSetVal(d, de, val);
void kvstoreDictSetVal(dictEntry *de, void *val) {
dictSetVal(de, val);
}

dictEntry *kvstoreDictTwoPhaseUnlinkFind(kvstore *kvs, int didx, const void *key, dictEntry ***plink, int *table_index) {
Expand Down
2 changes: 1 addition & 1 deletion src/kvstore.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ void *kvstoreDictFetchValue(kvstore *kvs, int didx, const void *key);
dictEntry *kvstoreDictFind(kvstore *kvs, int didx, void *key);
dictEntry *kvstoreDictAddRaw(kvstore *kvs, int didx, void *key, dictEntry **existing);
void kvstoreDictSetKey(kvstore *kvs, int didx, dictEntry* de, void *key);
void kvstoreDictSetVal(kvstore *kvs, int didx, dictEntry *de, void *val);
void kvstoreDictSetVal(dictEntry *de, void *val);
dictEntry *kvstoreDictTwoPhaseUnlinkFind(kvstore *kvs, int didx, const void *key, dictEntry ***plink, int *table_index);
void kvstoreDictTwoPhaseUnlinkFree(kvstore *kvs, int didx, dictEntry *he, dictEntry **plink, int table_index);
int kvstoreDictDelete(kvstore *kvs, int didx, const void *key);
Expand Down
1 change: 0 additions & 1 deletion src/latency.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
2 changes: 0 additions & 2 deletions src/module.c
Original file line number Diff line number Diff line change
Expand Up @@ -11945,7 +11945,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 */
Expand Down Expand Up @@ -11973,7 +11972,6 @@ void moduleInitModulesSystemLast(void) {
dictType sdsKeyValueHashDictType = {
dictSdsCaseHash, /* hash function */
NULL, /* key dup */
NULL, /* val dup */
dictSdsKeyCaseCompare, /* key compare */
dictSdsDestructor, /* key destructor */
dictSdsDestructor, /* val destructor */
Expand Down
2 changes: 1 addition & 1 deletion src/pubsub.c
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ int pubsubSubscribeChannel(client *c, robj *channel, pubsubtype type) {
channel = dictGetKey(existing);
} else {
clients = dictCreate(&clientDictType);
kvstoreDictSetVal(*type.serverPubSubChannels, slot, de, clients);
kvstoreDictSetVal(de, clients);
incrRefCount(channel);
}

Expand Down
1 change: 0 additions & 1 deletion src/redis-benchmark.c
Original file line number Diff line number Diff line change
Expand Up @@ -1285,7 +1285,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 */
Expand Down
4 changes: 0 additions & 4 deletions src/redis-cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -896,7 +896,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 */
Expand Down Expand Up @@ -3703,7 +3702,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 */
Expand All @@ -3713,7 +3711,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 */
Expand Down Expand Up @@ -9000,7 +8997,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 */
Expand Down

0 comments on commit 91a2462

Please sign in to comment.