mirror of
https://codeberg.org/redict/redict.git
synced 2025-01-23 16:48: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;
|
x = zsl->header;
|
||||||
for (i = zsl->level-1; i >= 0; i--) {
|
for (i = zsl->level-1; i >= 0; i--) {
|
||||||
while (x->level[i].forward && (range->minex ?
|
while (x->level[i].forward &&
|
||||||
x->level[i].forward->score <= range->min :
|
!zslValueGteMin(x->level[i].forward->score, range))
|
||||||
x->level[i].forward->score < range->min))
|
|
||||||
x = x->level[i].forward;
|
x = x->level[i].forward;
|
||||||
update[i] = x;
|
update[i] = x;
|
||||||
}
|
}
|
||||||
@ -399,9 +398,7 @@ unsigned long zslDeleteRangeByScore(zskiplist *zsl, zrangespec *range, dict *dic
|
|||||||
x = x->level[0].forward;
|
x = x->level[0].forward;
|
||||||
|
|
||||||
/* Delete nodes while in range. */
|
/* Delete nodes while in range. */
|
||||||
while (x &&
|
while (x && zslValueLteMax(x->score, range)) {
|
||||||
(range->maxex ? x->score < range->max : x->score <= range->max))
|
|
||||||
{
|
|
||||||
zskiplistNode *next = x->level[0].forward;
|
zskiplistNode *next = x->level[0].forward;
|
||||||
zslDeleteNode(zsl,x,update);
|
zslDeleteNode(zsl,x,update);
|
||||||
dictDelete(dict,x->ele);
|
dictDelete(dict,x->ele);
|
||||||
|
Loading…
Reference in New Issue
Block a user