mirror of
https://codeberg.org/redict/redict.git
synced 2025-01-23 08:38:27 -05:00
reuse existing range comparators in the zset (#8714)
There are 2 common range comparators for skiplist: zslValueGteMin and zslValueLteMax, but they're not being reused in zslDeleteRangeByScore This is a small change to make code cleaner.
This commit is contained in:
parent
07f39ae47b
commit
e5d50b236c
@ -388,9 +388,8 @@ unsigned long zslDeleteRangeByScore(zskiplist *zsl, zrangespec *range, dict *dic
|
||||
|
||||
x = zsl->header;
|
||||
for (i = zsl->level-1; i >= 0; i--) {
|
||||
while (x->level[i].forward && (range->minex ?
|
||||
x->level[i].forward->score <= range->min :
|
||||
x->level[i].forward->score < range->min))
|
||||
while (x->level[i].forward &&
|
||||
!zslValueGteMin(x->level[i].forward->score, range))
|
||||
x = x->level[i].forward;
|
||||
update[i] = x;
|
||||
}
|
||||
@ -399,9 +398,7 @@ unsigned long zslDeleteRangeByScore(zskiplist *zsl, zrangespec *range, dict *dic
|
||||
x = x->level[0].forward;
|
||||
|
||||
/* Delete nodes while in range. */
|
||||
while (x &&
|
||||
(range->maxex ? x->score < range->max : x->score <= range->max))
|
||||
{
|
||||
while (x && zslValueLteMax(x->score, range)) {
|
||||
zskiplistNode *next = x->level[0].forward;
|
||||
zslDeleteNode(zsl,x,update);
|
||||
dictDelete(dict,x->ele);
|
||||
|
Loading…
Reference in New Issue
Block a user