added an union in the dict.h structure to store 64 bit integers directly into hash table entries.

This commit is contained in:
antirez
2011-11-02 15:28:45 +01:00
parent ef23f3ac92
commit 6a7841eb09
2 changed files with 12 additions and 7 deletions

View File

@ -270,7 +270,7 @@ int dictAdd(dict *d, void *key, void *val)
if ((index = _dictKeyIndex(d, key)) == -1)
return DICT_ERR;
/* Allocates the memory and stores key */
/* Allocate the memory and store the new entry */
ht = dictIsRehashing(d) ? &d->ht[1] : &d->ht[0];
entry = zmalloc(sizeof(*entry));
entry->next = ht->table[index];
@ -297,7 +297,6 @@ int dictReplace(dict *d, void *key, void *val)
return 1;
/* It already exists, get the entry */
entry = dictFind(d, key);
/* Free the old value and set the new one */
/* Set the new value and free the old one. Note that it is important
* to do that in this order, as the value may just be exactly the same
* as the previous one. In this context, think to reference counting,