summaryrefslogtreecommitdiffstats
path: root/Objects/rangeobject.c
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2002-06-04 18:45:50 (GMT)
committerRaymond Hettinger <python@rcn.com>2002-06-04 18:45:50 (GMT)
commite53e7a2c7db0b940768c7f111c038a883c5962c1 (patch)
tree08545c32e2546c6792af9afb28e73c8bf5a12af0 /Objects/rangeobject.c
parentb0dc1a38a1e0ec7cb072db73ae8a18cf464243e8 (diff)
downloadcpython-e53e7a2c7db0b940768c7f111c038a883c5962c1.zip
cpython-e53e7a2c7db0b940768c7f111c038a883c5962c1.tar.gz
cpython-e53e7a2c7db0b940768c7f111c038a883c5962c1.tar.bz2
Inverted test for small speedup
Diffstat (limited to 'Objects/rangeobject.c')
-rw-r--r--Objects/rangeobject.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/Objects/rangeobject.c b/Objects/rangeobject.c
index 8e8f77e..26050c1 100644
--- a/Objects/rangeobject.c
+++ b/Objects/rangeobject.c
@@ -116,11 +116,10 @@ range_getiter(rangeobject *r)
static PyObject *
range_next(rangeobject *r)
{
- if (r->index >= r->len) {
- PyErr_SetObject(PyExc_StopIteration, Py_None);
- return NULL;
- }
- return PyInt_FromLong(r->start + (r->index++) * r->step);
+ if (r->index < r->len)
+ return PyInt_FromLong(r->start + (r->index++) * r->step);
+ PyErr_SetObject(PyExc_StopIteration, Py_None);
+ return NULL;
}
static PyMethodDef range_methods[] = {