Commit 3c68de9b authored by antirez's avatar antirez
Browse files

faster Set loading time from .rdb file resizing the hash table to the right...

faster Set loading time from .rdb file resizing the hash table to the right size before loading elements
parent 9651a787
...@@ -3335,6 +3335,10 @@ static robj *rdbLoadObject(int type, FILE *fp) { ...@@ -3335,6 +3335,10 @@ static robj *rdbLoadObject(int type, FILE *fp) {
if ((listlen = rdbLoadLen(fp,NULL)) == REDIS_RDB_LENERR) return NULL; if ((listlen = rdbLoadLen(fp,NULL)) == REDIS_RDB_LENERR) return NULL;
o = (type == REDIS_LIST) ? createListObject() : createSetObject(); o = (type == REDIS_LIST) ? createListObject() : createSetObject();
/* It's faster to expand the dict to the right size asap in order
* to avoid rehashing */
if (type == REDIS_SET && listlen > DICT_HT_INITIAL_SIZE)
dictExpand(o->ptr,listlen);
/* Load every single element of the list/set */ /* Load every single element of the list/set */
while(listlen--) { while(listlen--) {
robj *ele; robj *ele;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment