Merge pull request #4800 from soloestoy/dict-expand

adjust position of _dictNextPower in dictExpand
This commit is contained in:
Salvatore Sanfilippo 2018-06-08 12:32:18 +02:00 committed by GitHub
commit 5ebaadc96b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -146,14 +146,14 @@ int dictResize(dict *d)
/* Expand or create the hash table */
int dictExpand(dict *d, unsigned long size)
{
dictht n; /* the new hash table */
unsigned long realsize = _dictNextPower(size);
/* the size is invalid if it is smaller than the number of
* elements already inside the hash table */
if (dictIsRehashing(d) || d->ht[0].used > size)
return DICT_ERR;
dictht n; /* the new hash table */
unsigned long realsize = _dictNextPower(size);
/* Rehashing to the same table size is not useful. */
if (realsize == d->ht[0].size) return DICT_ERR;