]> granicus.if.org Git - python/commitdiff
Remove unnecessary modulo division.
authorRaymond Hettinger <python@rcn.com>
Fri, 8 Feb 2008 22:30:04 +0000 (22:30 +0000)
committerRaymond Hettinger <python@rcn.com>
Fri, 8 Feb 2008 22:30:04 +0000 (22:30 +0000)
The preceding test guarantees that 0 <= i < len.

Objects/rangeobject.c

index c48bee0164e7a6050a05b74dff7bd4a558a332a3..da4356b9f1601b0b269293a7c5d6dfb59ba5bf44 100644 (file)
@@ -98,7 +98,7 @@ range_item(rangeobject *r, Py_ssize_t i)
                                "xrange object index out of range");
                return NULL;
        }
-       return PyInt_FromSsize_t(r->start + (i % r->len) * r->step);
+       return PyInt_FromSsize_t(r->start + i * r->step);
 }
 
 static Py_ssize_t