diff options
author | antirez <antirez@gmail.com> | 2012-10-31 09:23:05 +0100 |
---|---|---|
committer | antirez <antirez@gmail.com> | 2012-10-31 09:23:05 +0100 |
commit | 973cb21a0152642ec904cf8f8ab238a31e6ebaa9 (patch) | |
tree | 1c1b3e2bf983f33e85be6bd20574196d5effb457 /src/t_string.c | |
parent | b16e423430465013c14af1550f29e7c25c3a433c (diff) | |
download | redis-973cb21a0152642ec904cf8f8ab238a31e6ebaa9.tar.gz |
Invert two sides of if expression in SET to avoid a lookup.
Because of the short circuit behavior of && inverting the two sides of
the if expression avoids an hash table lookup if the non-EX variant of
SET is called.
Thanks to Weibin Yao (@yaoweibin on github) for spotting this.
Diffstat (limited to 'src/t_string.c')
-rw-r--r-- | src/t_string.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/t_string.c b/src/t_string.c index 1e29a6133..ba4279613 100644 --- a/src/t_string.c +++ b/src/t_string.c @@ -26,7 +26,7 @@ void setGenericCommand(redisClient *c, int nx, robj *key, robj *val, robj *expir if (unit == UNIT_SECONDS) milliseconds *= 1000; } - if (lookupKeyWrite(c->db,key) != NULL && nx) { + if (nx && lookupKeyWrite(c->db,key) != NULL) { addReply(c,shared.czero); return; } |