Skip to content

Commit

Permalink
Avoid using low level dictAddRaw() and dictSetKey() for ZUNION operat…
Browse files Browse the repository at this point in the history
…ion.
  • Loading branch information
QuChen88 committed Jan 4, 2025
1 parent b3b4bdc commit 2b3ceff
Showing 1 changed file with 3 additions and 3 deletions.
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

0 comments on commit 2b3ceff

Please sign in to comment.