mirror of
https://github.com/redis/redis.git
synced 2026-02-03 20:39:54 -05:00
break the while loop immediately when level is bigger than ZSKIPLIST_MAXLEVEL
This commit is contained in:
parent
731f2dc5c7
commit
3ab5af484c
1 changed files with 1 additions and 1 deletions
|
|
@ -126,7 +126,7 @@ void zslFree(zskiplist *zsl) {
|
|||
int zslRandomLevel(void) {
|
||||
static const int threshold = ZSKIPLIST_P*RAND_MAX;
|
||||
int level = 1;
|
||||
while (random() < threshold)
|
||||
while (random() < threshold && level < ZSKIPLIST_MAXLEVEL)
|
||||
level += 1;
|
||||
return (level<ZSKIPLIST_MAXLEVEL) ? level : ZSKIPLIST_MAXLEVEL;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue