]> git.saurik.com Git - redis.git/commitdiff
merged code from 184d74ab, 4774a53b, f483ce5f to new file structure
authorPieter Noordhuis <pcnoordhuis@gmail.com>
Mon, 5 Jul 2010 19:16:33 +0000 (15:16 -0400)
committerPieter Noordhuis <pcnoordhuis@gmail.com>
Mon, 5 Jul 2010 19:16:33 +0000 (15:16 -0400)
src/t_list.c
src/t_zset.c

index ec8b30c3fbb0b701c3e0cda7512ecc085d34f509..0568fff119d47eba28b9896f31cdec9c1419eb49 100644 (file)
@@ -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;
index de32a8eedf7667c4795de5446dce9aa11c359bcb..26a80e994f793e7cb64e92901895229380e0e15a 100644 (file)
@@ -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;
     }