diff options
author | 天河 <w1s2j3229@163.com> | 2020-09-09 20:28:38 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-09 15:28:38 +0300 |
commit | 63730d9dd0a9fea63e460938407ed7bee9303ee0 (patch) | |
tree | 611f2c76e2672e2d4604b38c01b3b1665221c3d2 /src/quicklist.c | |
parent | 818a746e32de934c6c6e828ccf39df361361037e (diff) | |
download | redis-63730d9dd0a9fea63e460938407ed7bee9303ee0.tar.gz |
Fix comments of _quicklistSplitNode function. (#4341)
Comments about the behavior of the function where wrong (off by one)
Co-authored-by: Oran Agra <oran@redislabs.com>
Diffstat (limited to 'src/quicklist.c')
-rw-r--r-- | src/quicklist.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/quicklist.c b/src/quicklist.c index 52e3988f5..0916d1f1b 100644 --- a/src/quicklist.c +++ b/src/quicklist.c @@ -797,16 +797,16 @@ REDIS_STATIC void _quicklistMergeNodes(quicklist *quicklist, * The 'after' argument controls which quicklistNode gets returned. * If 'after'==1, returned node has elements after 'offset'. * input node keeps elements up to 'offset', including 'offset'. - * If 'after'==0, returned node has elements up to 'offset', including 'offset'. - * input node keeps elements after 'offset'. + * If 'after'==0, returned node has elements up to 'offset'. + * input node keeps elements after 'offset', including 'offset'. * - * If 'after'==1, returned node will have elements _after_ 'offset'. + * Or in other words: + * If 'after'==1, returned node will have elements after 'offset'. * The returned node will have elements [OFFSET+1, END]. * The input node keeps elements [0, OFFSET]. - * - * If 'after'==0, returned node will keep elements up to and including 'offset'. - * The returned node will have elements [0, OFFSET]. - * The input node keeps elements [OFFSET+1, END]. + * If 'after'==0, returned node will keep elements up to but not including 'offset'. + * The returned node will have elements [0, OFFSET-1]. + * The input node keeps elements [OFFSET, END]. * * The input node keeps all elements not taken by the returned node. * @@ -821,7 +821,7 @@ REDIS_STATIC quicklistNode *_quicklistSplitNode(quicklistNode *node, int offset, /* Copy original ziplist so we can split it */ memcpy(new_node->zl, node->zl, zl_sz); - /* -1 here means "continue deleting until the list ends" */ + /* Ranges to be trimmed: -1 here means "continue deleting until the list ends" */ int orig_start = after ? offset + 1 : 0; int orig_extent = after ? -1 : offset; int new_start = after ? 0 : offset; |