Remove useless complexity from MSET implementation.

This commit is contained in:
antirez 2018-10-22 12:24:02 +02:00
parent f30b18f4de
commit c33ef454f0

View File

@ -301,24 +301,22 @@ void mgetCommand(client *c) {
} }
void msetGenericCommand(client *c, int nx) { void msetGenericCommand(client *c, int nx) {
int j, busykeys = 0; int j;
if ((c->argc % 2) == 0) { if ((c->argc % 2) == 0) {
addReplyError(c,"wrong number of arguments for MSET"); addReplyError(c,"wrong number of arguments for MSET");
return; return;
} }
/* Handle the NX flag. The MSETNX semantic is to return zero and don't /* Handle the NX flag. The MSETNX semantic is to return zero and don't
* set nothing at all if at least one already key exists. */ * set anything if at least one key alerady exists. */
if (nx) { if (nx) {
for (j = 1; j < c->argc; j += 2) { for (j = 1; j < c->argc; j += 2) {
if (lookupKeyWrite(c->db,c->argv[j]) != NULL) { if (lookupKeyWrite(c->db,c->argv[j]) != NULL) {
busykeys++; addReply(c, shared.czero);
return;
} }
} }
if (busykeys) {
addReply(c, shared.czero);
return;
}
} }
for (j = 1; j < c->argc; j += 2) { for (j = 1; j < c->argc; j += 2) {