mirror of
https://github.com/fluencelabs/redis
synced 2025-03-19 17:10:50 +00:00
Clarify why we save ziplist elements in revserse order.
Also get rid of variables that are now kinda redundant, since the dictionary iterator was removed. This is related to PR #3949.
This commit is contained in:
parent
0a942f1751
commit
c33493277a
20
src/rdb.c
20
src/rdb.c
@ -709,17 +709,23 @@ ssize_t rdbSaveObject(rio *rdb, robj *o) {
|
||||
if ((n = rdbSaveLen(rdb,zsl->length)) == -1) return -1;
|
||||
nwritten += n;
|
||||
|
||||
/* We save the skiplist elements from the greatest to the smallest
|
||||
* (that's trivial since the elements are already ordered in the
|
||||
* skiplist): this improves the load process, since the next loaded
|
||||
* element will always be the smaller, so adding to the skiplist
|
||||
* will always immediately stop at the head, making the insertion
|
||||
* O(1) instead of O(log(N)). */
|
||||
zskiplistNode *zn = zsl->tail;
|
||||
while (zn != NULL) {
|
||||
sds ele = zn->ele;
|
||||
double *score = &zn->score;
|
||||
|
||||
if ((n = rdbSaveRawString(rdb,(unsigned char*)ele,sdslen(ele)))
|
||||
== -1) return -1;
|
||||
if ((n = rdbSaveRawString(rdb,
|
||||
(unsigned char*)zn->ele,sdslen(zn->ele))) == -1)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
nwritten += n;
|
||||
if ((n = rdbSaveBinaryDoubleValue(rdb,*score)) == -1) return -1;
|
||||
if ((n = rdbSaveBinaryDoubleValue(rdb,zn->score)) == -1)
|
||||
return -1;
|
||||
nwritten += n;
|
||||
|
||||
zn = zn->backward;
|
||||
}
|
||||
} else {
|
||||
|
Loading…
x
Reference in New Issue
Block a user