From 777020839a1ba68ea5bd77a5b17648f4b831caf7 Mon Sep 17 00:00:00 2001 From: antirez Date: Thu, 5 Feb 2015 10:42:09 +0100 Subject: [PATCH] dict.c: prevent useless resize to same size. Related to issue #2306. --- src/dict.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/dict.c b/src/dict.c index a1475772..26707dd5 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;