summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2015-02-05 10:42:09 +0100
committerantirez <antirez@gmail.com>2015-02-08 23:08:21 +0100
commit7e5031ea18c77bcf8709cf3b0f7052e455ae7346 (patch)
treea1b0f6b5707f43c05fe5ce9a978bb08c33fb8c06
parent6bda18ff1e7b995b39c56fdb59cfd5ad028202bf (diff)
downloadredis-7e5031ea18c77bcf8709cf3b0f7052e455ae7346.tar.gz
dict.c: prevent useless resize to same size.
Related to issue #2306.
-rw-r--r--src/dict.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/dict.c b/src/dict.c
index a1475772c..26707dd58 100644
--- a/src/dict.c
+++ b/src/dict.c
@@ -211,6 +211,9 @@ int dictExpand(dict *d, unsigned long size)
if (dictIsRehashing(d) || d->ht[0].used > size)
return DICT_ERR;
+ /* Rehashing to the same table size is not useful. */
+ if (realsize == d->ht[0].size) return DICT_ERR;
+
/* Allocate the new hash table and initialize all pointers to NULL */
n.size = realsize;
n.sizemask = realsize-1;