Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
51829ed3
Commit
51829ed3
authored
May 17, 2009
by
Aman Gupta
Browse files
Optimize SDIFF to return as soon as the result set is empty
parent
f4f56e1d
Changes
1
Hide whitespace changes
Inline
Side-by-side
redis.c
View file @
51829ed3
...
...
@@ -3112,6 +3112,7 @@ static void sunionDiffGenericCommand(redisClient *c, robj **setskeys, int setsnu
/* Iterate all the elements of all the sets, add every element a single
* time to the result set */
for (j = 0; j < setsnum; j++) {
if (op == REDIS_OP_DIFF && j == 0 && !dv[j]) break; /* result set is empty */
if (!dv[j]) continue; /* non existing keys are like empty sets */
di = dictGetIterator(dv[j]);
...
...
@@ -3134,6 +3135,8 @@ static void sunionDiffGenericCommand(redisClient *c, robj **setskeys, int setsnu
}
}
dictReleaseIterator(di);
if (op == REDIS_OP_DIFF && cardinality == 0) break; /* result set is empty */
}
/* Output the content of the resulting set, if not in STORE mode */
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment