diff options
author | Stefan Behnel <stefan_ml@behnel.de> | 2017-08-25 10:19:26 +0200 |
---|---|---|
committer | Stefan Behnel <stefan_ml@behnel.de> | 2017-08-25 10:19:26 +0200 |
commit | ccfeb8175575019c9ccda482936fbc3f1ea1d2f0 (patch) | |
tree | 1c07a1b6bedf0108cb4ec8860e1a65719309fa79 | |
parent | 98b60d8f59f845b9b33782e822b251ac083c7996 (diff) | |
download | cython-ccfeb8175575019c9ccda482936fbc3f1ea1d2f0.tar.gz |
Add branch hints to __Pyx_Coroutine_Close() to optimise for the normal case.
-rw-r--r-- | Cython/Utility/Coroutine.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/Cython/Utility/Coroutine.c b/Cython/Utility/Coroutine.c index f12868cbc..cf995db6d 100644 --- a/Cython/Utility/Coroutine.c +++ b/Cython/Utility/Coroutine.c @@ -904,7 +904,7 @@ static PyObject *__Pyx_Coroutine_Close(PyObject *self) { if (err == 0) PyErr_SetNone(PyExc_GeneratorExit); retval = __Pyx_Coroutine_SendEx(gen, NULL, 1); - if (retval) { + if (unlikely(retval)) { const char *msg; Py_DECREF(retval); if (0) { @@ -927,7 +927,7 @@ static PyObject *__Pyx_Coroutine_Close(PyObject *self) { return NULL; } raised_exception = PyErr_Occurred(); - if (!raised_exception || __Pyx_PyErr_GivenExceptionMatches2(raised_exception, PyExc_GeneratorExit, PyExc_StopIteration)) { + if (likely(!raised_exception || __Pyx_PyErr_GivenExceptionMatches2(raised_exception, PyExc_GeneratorExit, PyExc_StopIteration))) { // ignore these errors if (raised_exception) PyErr_Clear(); Py_INCREF(Py_None); |