Skip to content

Commit

Permalink
faster Set loading time from .rdb file resizing the hash table to the…
Browse files Browse the repository at this point in the history
… right size before loading elements
  • Loading branch information
antirez committed Feb 2, 2010
1 parent 9651a78 commit 3c68de9
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions redis.c
Original file line number Diff line number Diff line change
Expand Up @@ -3335,6 +3335,10 @@ static robj *rdbLoadObject(int type, FILE *fp) {

if ((listlen = rdbLoadLen(fp,NULL)) == REDIS_RDB_LENERR) return NULL;
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 */
while(listlen--) {
robj *ele;
Expand Down

0 comments on commit 3c68de9

Please sign in to comment.