Commit 1fce8d80 authored by Stefan Behnel's avatar Stefan Behnel

Avoid exception type check in next() implementation if we don't have a default...

Avoid exception type check in next() implementation if we don't have a default value to return anyway.
See #2116.
parent 47102585
...@@ -170,12 +170,10 @@ static PyObject *__Pyx_PyIter_Next2Default(PyObject* defval) { ...@@ -170,12 +170,10 @@ static PyObject *__Pyx_PyIter_Next2Default(PyObject* defval) {
__Pyx_PyThreadState_assign __Pyx_PyThreadState_assign
exc_type = __Pyx_PyErr_Occurred(); exc_type = __Pyx_PyErr_Occurred();
if (unlikely(exc_type)) { if (unlikely(exc_type)) {
if (unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) if (!defval || unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration)))
return NULL; return NULL;
if (defval) {
__Pyx_PyErr_Clear(); __Pyx_PyErr_Clear();
Py_INCREF(defval); Py_INCREF(defval);
}
return defval; return defval;
} }
if (defval) { if (defval) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment