Skip to content

Commit 8dca801

Browse files
authored
Remove redundancy if condition statement (#2034)
Before the if condition, the sdslen(value) can not be zero or negative, thus this if condition is redundancy , just remove it. Signed-off-by: hwware <wen.hui.ware@gmail.com>
1 parent 4eeffda commit 8dca801

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

src/t_string.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -553,14 +553,11 @@ void setrangeCommand(client *c) {
553553
o = dbUnshareStringValue(c->db, c->argv[1], o);
554554
}
555555

556-
if (sdslen(value) > 0) {
557-
o->ptr = sdsgrowzero(o->ptr, offset + sdslen(value));
558-
memcpy((char *)o->ptr + offset, value, sdslen(value));
559-
signalModifiedKey(c, c->db, c->argv[1]);
560-
notifyKeyspaceEvent(NOTIFY_STRING,
561-
"setrange", c->argv[1], c->db->id);
562-
server.dirty++;
563-
}
556+
o->ptr = sdsgrowzero(o->ptr, offset + sdslen(value));
557+
memcpy((char *)o->ptr + offset, value, sdslen(value));
558+
signalModifiedKey(c, c->db, c->argv[1]);
559+
notifyKeyspaceEvent(NOTIFY_STRING, "setrange", c->argv[1], c->db->id);
560+
server.dirty++;
564561
addReplyLongLong(c, sdslen(o->ptr));
565562
}
566563

0 commit comments

Comments
 (0)