diff options
author | Wen Hui <wen.hui.ware@gmail.com> | 2020-08-20 17:14:09 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-21 00:14:09 +0300 |
commit | 89f2bfbb58b907129de38917a7ae12c3b948daa6 (patch) | |
tree | 5c4527d361e7fdcf7662cf81e9d572243e69c5c4 /src | |
parent | a3d4d7bf68bf825584b34785ed2b117dd24c1754 (diff) | |
download | redis-89f2bfbb58b907129de38917a7ae12c3b948daa6.tar.gz |
use dictSlots for getting total slots number in dict (#7691)
Diffstat (limited to 'src')
-rw-r--r-- | src/dict.c | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/src/dict.c b/src/dict.c index a26ef18d3..39af94707 100644 --- a/src/dict.c +++ b/src/dict.c @@ -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); |