From: Pieter Noordhuis Date: Mon, 5 Jul 2010 19:16:33 +0000 (-0400) Subject: merged code from 184d74ab, 4774a53b, f483ce5f to new file structure X-Git-Url: https://git.saurik.com/redis.git/commitdiff_plain/d0a4e24e321ced2324b0ad4b6be34f13f90e9b90 merged code from 184d74ab, 4774a53b, f483ce5f to new file structure --- diff --git a/src/t_list.c b/src/t_list.c index ec8b30c3..0568fff1 100644 --- a/src/t_list.c +++ b/src/t_list.c @@ -476,11 +476,10 @@ void lrangeCommand(redisClient *c) { if (start < 0) start = llen+start; if (end < 0) end = llen+end; if (start < 0) start = 0; - if (end < 0) end = 0; - /* indexes sanity checks */ + /* Invariant: start >= 0, so this test will be true when end < 0. + * The range is empty when start > end or start >= length. */ if (start > end || start >= llen) { - /* Out of range start or start > end result in empty list */ addReply(c,shared.emptymultibulk); return; } @@ -516,9 +515,9 @@ void ltrimCommand(redisClient *c) { if (start < 0) start = llen+start; if (end < 0) end = llen+end; if (start < 0) start = 0; - if (end < 0) end = 0; - /* indexes sanity checks */ + /* Invariant: start >= 0, so this test will be true when end < 0. + * The range is empty when start > end or start >= length. */ if (start > end || start >= llen) { /* Out of range start or start > end result in empty list */ ltrim = llen; diff --git a/src/t_zset.c b/src/t_zset.c index de32a8ee..26a80e99 100644 --- a/src/t_zset.c +++ b/src/t_zset.c @@ -497,9 +497,9 @@ void zremrangebyrankCommand(redisClient *c) { if (start < 0) start = llen+start; if (end < 0) end = llen+end; if (start < 0) start = 0; - if (end < 0) end = 0; - /* indexes sanity checks */ + /* Invariant: start >= 0, so this test will be true when end < 0. + * The range is empty when start > end or start >= length. */ if (start > end || start >= llen) { addReply(c,shared.czero); return; @@ -750,11 +750,10 @@ void zrangeGenericCommand(redisClient *c, int reverse) { if (start < 0) start = llen+start; if (end < 0) end = llen+end; if (start < 0) start = 0; - if (end < 0) end = 0; - /* indexes sanity checks */ + /* Invariant: start >= 0, so this test will be true when end < 0. + * The range is empty when start > end or start >= length. */ if (start > end || start >= llen) { - /* Out of range start or start > end result in empty list */ addReply(c,shared.emptymultibulk); return; }