use dictSlots for getting total slots number in dict (#7691)

This commit is contained in:
Wen Hui
2020-08-20 17:14:09 -04:00
committed by GitHub
parent a3d4d7bf68
commit 89f2bfbb58

View File

@@ -621,9 +621,7 @@ dictEntry *dictGetRandomKey(dict *d)
do {
/* We are sure there are no elements in indexes from 0
* to rehashidx-1 */
h = d->rehashidx + (random() % (d->ht[0].size +
d->ht[1].size -
d->rehashidx));
h = d->rehashidx + (random() % (dictSlots(d) - d->rehashidx));
he = (h >= d->ht[0].size) ? d->ht[1].table[h - d->ht[0].size] :
d->ht[0].table[h];
} while(he == NULL);