From: antirez Date: Tue, 2 Feb 2010 11:05:15 +0000 (+0100) Subject: faster Set loading time from .rdb file resizing the hash table to the right size... X-Git-Url: https://git.saurik.com/redis.git/commitdiff_plain/3c68de9b0107a0a15eef09edf86464d1434048e7?ds=inline faster Set loading time from .rdb file resizing the hash table to the right size before loading elements --- diff --git a/redis.c b/redis.c index 36055c4c..e095e695 100644 --- a/redis.c +++ b/redis.c @@ -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;