]> granicus.if.org Git - python/commitdiff
Inverted test for small speedup
authorRaymond Hettinger <python@rcn.com>
Tue, 4 Jun 2002 18:45:50 +0000 (18:45 +0000)
committerRaymond Hettinger <python@rcn.com>
Tue, 4 Jun 2002 18:45:50 +0000 (18:45 +0000)
Objects/rangeobject.c

index 8e8f77e610df4437df667acecb81f57643c971cc..26050c1d39ffeaf5ddcf06fc0f8523f005f835c9 100644 (file)
@@ -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[] = {