diff options
author | antirez <antirez@gmail.com> | 2013-08-16 15:31:25 +0200 |
---|---|---|
committer | antirez <antirez@gmail.com> | 2013-08-16 15:31:38 +0200 |
commit | 45217a78a9f1403600be4cd2f719054ad42e01be (patch) | |
tree | 4aff2e36e9b2bc262a08a78f23052006bcb39ec2 | |
parent | 104e304b62233d3b5ec7431ca45eb76614ca23a4 (diff) | |
download | redis-45217a78a9f1403600be4cd2f719054ad42e01be.tar.gz |
Fix comments for correctness in zunionInterGenericCommand().
Related to issue #1240.
-rw-r--r-- | src/t_zset.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/t_zset.c b/src/t_zset.c index 20ff84b2e..1fcfd6bb6 100644 --- a/src/t_zset.c +++ b/src/t_zset.c @@ -1640,7 +1640,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; @@ -1648,8 +1648,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. */ |