]> git.saurik.com Git - redis.git/commitdiff
faster Set loading time from .rdb file resizing the hash table to the right size...
authorantirez <antirez@gmail.com>
Tue, 2 Feb 2010 11:05:15 +0000 (12:05 +0100)
committerantirez <antirez@gmail.com>
Tue, 2 Feb 2010 11:05:15 +0000 (12:05 +0100)
redis.c

diff --git a/redis.c b/redis.c
index 36055c4c92425ea6d6af3d1ce91e89ca55dc5829..e095e6952ec6351b46f7d984a185f3b24d3a2ba1 100644 (file)
--- 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;