Skip to content

Commit

Permalink
remove dedup lookup
Browse files Browse the repository at this point in the history
Signed-off-by: Sarthak Aggarwal <[email protected]>
  • Loading branch information
sarthakaggarwal97 committed Nov 20, 2024
1 parent f796577 commit f5ec47c
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/t_string.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,20 +102,20 @@ void setGenericCommand(client *c,
if (getGenericCommand(c) == C_ERR) return;
}

found = (lookupKeyWrite(c->db, key) != NULL);
const robj *value = lookupKeyWrite(c->db, key);
found = value != NULL;

/* Handle the IFEQ conditional check */
if (flags & OBJ_SET_IFEQ && found) {
robj *current_value = lookupKeyRead(c->db, key);

if (current_value->type != OBJ_STRING) {
if (value->type != OBJ_STRING) {
if (!(flags & OBJ_SET_GET)) {
addReplyError(c, "value(s) must be present or string");
}
return;
}

if (compareStringObjects(current_value, comparison) != 0) {
if (compareStringObjects(value, comparison) != 0) {
if (!(flags & OBJ_SET_GET)) {
addReply(c, abort_reply ? abort_reply : shared.null[c->resp]);
}
Expand Down

0 comments on commit f5ec47c

Please sign in to comment.