From 8aaf5075c5bb76492e56188090f33266d5a7ad46 Mon Sep 17 00:00:00 2001 From: antirez Date: Fri, 23 Jan 2015 18:11:05 +0100 Subject: [PATCH] dict.c: make chaining strategy more clear in dictAddRaw(). --- src/dict.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/dict.c b/src/dict.c index 29d400099..7d8db3631 100644 --- a/src/dict.c +++ b/src/dict.c @@ -342,7 +342,10 @@ dictEntry *dictAddRaw(dict *d, void *key) if ((index = _dictKeyIndex(d, key)) == -1) return NULL; - /* Allocate the memory and store the new entry */ + /* Allocate the memory and store the new entry. + * Insert the element in top, with the assumption that in a database + * system it is more likely that recently added entries are accessed + * more frequently. */ ht = dictIsRehashing(d) ? &d->ht[1] : &d->ht[0]; entry = zmalloc(sizeof(*entry)); entry->next = ht->table[index];