Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
89f2bfbb
Unverified
Commit
89f2bfbb
authored
Aug 20, 2020
by
Wen Hui
Committed by
GitHub
Aug 21, 2020
Browse files
use dictSlots for getting total slots number in dict (#7691)
parent
a3d4d7bf
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/dict.c
View file @
89f2bfbb
...
@@ -621,9 +621,7 @@ dictEntry *dictGetRandomKey(dict *d)
...
@@ -621,9 +621,7 @@ dictEntry *dictGetRandomKey(dict *d)
do
{
do
{
/* We are sure there are no elements in indexes from 0
/* We are sure there are no elements in indexes from 0
* to rehashidx-1 */
* to rehashidx-1 */
h
=
d
->
rehashidx
+
(
random
()
%
(
d
->
ht
[
0
].
size
+
h
=
d
->
rehashidx
+
(
random
()
%
(
dictSlots
(
d
)
-
d
->
rehashidx
));
d
->
ht
[
1
].
size
-
d
->
rehashidx
));
he
=
(
h
>=
d
->
ht
[
0
].
size
)
?
d
->
ht
[
1
].
table
[
h
-
d
->
ht
[
0
].
size
]
:
he
=
(
h
>=
d
->
ht
[
0
].
size
)
?
d
->
ht
[
1
].
table
[
h
-
d
->
ht
[
0
].
size
]
:
d
->
ht
[
0
].
table
[
h
];
d
->
ht
[
0
].
table
[
h
];
}
while
(
he
==
NULL
);
}
while
(
he
==
NULL
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment