@@ -208,30 +208,32 @@ calliter_traverse(calliterobject *it, visitproc visit, void *arg) |
|
|
208 |
208 |
static PyObject * |
209 |
209 |
calliter_iternext(calliterobject *it) |
210 |
210 |
{ |
211 |
|
-if (it->it_callable != NULL) { |
212 |
|
-PyObject *args = PyTuple_New(0); |
213 |
|
-PyObject *result; |
214 |
|
-if (args == NULL) |
215 |
|
-return NULL; |
216 |
|
-result = PyObject_Call(it->it_callable, args, NULL); |
217 |
|
-Py_DECREF(args); |
218 |
|
-if (result != NULL) { |
219 |
|
-int ok; |
220 |
|
-ok = PyObject_RichCompareBool(it->it_sentinel, result, Py_EQ); |
221 |
|
-if (ok == 0) |
222 |
|
-return result; /* Common case, fast path */ |
223 |
|
-Py_DECREF(result); |
224 |
|
-if (ok > 0) { |
225 |
|
-Py_CLEAR(it->it_callable); |
226 |
|
-Py_CLEAR(it->it_sentinel); |
227 |
|
- } |
|
211 |
+PyObject *result; |
|
212 |
+ |
|
213 |
+if (it->it_callable == NULL) { |
|
214 |
+return NULL; |
|
215 |
+ } |
|
216 |
+ |
|
217 |
+result = _PyObject_FastCall(it->it_callable, NULL, 0, NULL); |
|
218 |
+if (result != NULL) { |
|
219 |
+int ok; |
|
220 |
+ |
|
221 |
+ok = PyObject_RichCompareBool(it->it_sentinel, result, Py_EQ); |
|
222 |
+if (ok == 0) { |
|
223 |
+return result; /* Common case, fast path */ |
228 |
224 |
} |
229 |
|
-else if (PyErr_ExceptionMatches(PyExc_StopIteration)) { |
230 |
|
-PyErr_Clear(); |
|
225 |
+ |
|
226 |
+Py_DECREF(result); |
|
227 |
+if (ok > 0) { |
231 |
228 |
Py_CLEAR(it->it_callable); |
232 |
229 |
Py_CLEAR(it->it_sentinel); |
233 |
230 |
} |
234 |
231 |
} |
|
232 |
+else if (PyErr_ExceptionMatches(PyExc_StopIteration)) { |
|
233 |
+PyErr_Clear(); |
|
234 |
+Py_CLEAR(it->it_callable); |
|
235 |
+Py_CLEAR(it->it_sentinel); |
|
236 |
+ } |
235 |
237 |
return NULL; |
236 |
238 |
} |
237 |
239 |
|