mirror of
https://codeberg.org/redict/redict.git
synced 2025-01-22 16:18:28 -05:00
use dictSlots for getting total slots number in dict (#7691)
This commit is contained in:
parent
a3d4d7bf68
commit
89f2bfbb58
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user