summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2013-08-16 15:31:25 +0200
committerantirez <antirez@gmail.com>2013-08-19 15:02:06 +0200
commit836855073310a84648d125179e1506f12b8c59ca (patch)
treee45783ab2e7c675c65bde2761e117b979584c435
parent3ad87c652b601f8a5fa1ee4cbf6802ddc02c6ed7 (diff)
downloadredis-836855073310a84648d125179e1506f12b8c59ca.tar.gz
Fix comments for correctness in zunionInterGenericCommand().
Related to issue #1240.
-rw-r--r--src/t_zset.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/t_zset.c b/src/t_zset.c
index ed97a078f..b4cb9d00c 100644
--- a/src/t_zset.c
+++ b/src/t_zset.c
@@ -1639,7 +1639,7 @@ void zunionInterGenericCommand(redisClient *c, robj *dstkey, int op) {
while (zuiNext(&src[i],&zval)) {
double score, value;
- /* Skip key when already processed */
+ /* Skip an element that when already processed */
if (dictFind(dstzset->dict,zuiObjectFromValue(&zval)) != NULL)
continue;
@@ -1647,8 +1647,10 @@ void zunionInterGenericCommand(redisClient *c, robj *dstkey, int op) {
score = src[i].weight * zval.score;
if (isnan(score)) score = 0;
- /* Because the inputs are sorted by size, it's only possible
- * for sets at larger indices to hold this element. */
+ /* We need to check only next sets to see if this element
+ * exists, since we process every element just one time so
+ * it can't exist in a previous set (otherwise it would be
+ * already processed). */
for (j = (i+1); j < setnum; j++) {
/* It is not safe to access the zset we are
* iterating, so explicitly check for equal object. */