Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve readability and efficiency for ZUNION operation #1506

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/t_zset.c
Original file line number Diff line number Diff line change
Expand Up @@ -2793,7 +2793,7 @@ void zunionInterDiffGenericCommand(client *c, robj *dstkey, int numkeysIndex, in
if (isnan(score)) score = 0;

/* Search for this element in the accumulating dictionary. */
de = dictAddRaw(dstzset->dict, zuiSdsFromValue(&zval), &existing);
existing = dictFind(dstzset->dict, zuiSdsFromValue(&zval));
/* If we don't have it, we need to create a new entry. */
if (!existing) {
tmp = zuiNewSdsFromValue(&zval);
Expand All @@ -2802,8 +2802,8 @@ void zunionInterDiffGenericCommand(client *c, robj *dstkey, int numkeysIndex, in
* at the end. */
totelelen += sdslen(tmp);
if (sdslen(tmp) > maxelelen) maxelelen = sdslen(tmp);
/* Update the element with its initial score. */
dictSetKey(dstzset->dict, de, tmp);
/* Insert the element with its initial score. */
de = dictAddRaw(dstzset->dict, tmp, NULL);
dictSetDoubleVal(de, score);
} else {
/* Update the score with the score of the new instance
Expand Down
Loading