From fb0fe5485548f9ad1afb99e495db207273febd5e Mon Sep 17 00:00:00 2001 From: Robert Bradshaw Date: Thu, 26 Feb 2009 22:35:00 -0800 Subject: [PATCH] more branch avoidance --- Cython/Compiler/ExprNodes.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Cython/Compiler/ExprNodes.py b/Cython/Compiler/ExprNodes.py index 71885d31..abdc726f 100644 --- a/Cython/Compiler/ExprNodes.py +++ b/Cython/Compiler/ExprNodes.py @@ -5411,7 +5411,7 @@ static INLINE PyObject *__Pyx_GetItemInt_Generic(PyObject *o, Py_ssize_t i, int } static INLINE PyObject *__Pyx_GetItemInt_List(PyObject *o, Py_ssize_t i, int is_unsigned) { - if (likely(o != Py_None && 0 <= i && i < PyList_GET_SIZE(o))) { + if (likely(o != Py_None && ((0 <= i) & (i < PyList_GET_SIZE(o))))) { PyObject *r = PyList_GET_ITEM(o, i); Py_INCREF(r); return r; @@ -5420,7 +5420,7 @@ static INLINE PyObject *__Pyx_GetItemInt_List(PyObject *o, Py_ssize_t i, int is_ } static INLINE PyObject *__Pyx_GetItemInt_Tuple(PyObject *o, Py_ssize_t i, int is_unsigned) { - if (likely(o != Py_None && 0 <= i && i < PyTuple_GET_SIZE(o))) { + if (likely(o != Py_None && ((0 <= i) & (i < PyTuple_GET_SIZE(o))))) { PyObject *r = PyTuple_GET_ITEM(o, i); Py_INCREF(r); return r; @@ -5430,11 +5430,11 @@ static INLINE PyObject *__Pyx_GetItemInt_Tuple(PyObject *o, Py_ssize_t i, int is static INLINE PyObject *__Pyx_GetItemInt(PyObject *o, Py_ssize_t i, int is_unsigned) { PyObject *r; - if (PyList_CheckExact(o) && 0 <= i && i < PyList_GET_SIZE(o)) { + if (PyList_CheckExact(o) && ((0 <= i) & (i < PyList_GET_SIZE(o)))) { r = PyList_GET_ITEM(o, i); Py_INCREF(r); } - else if (PyTuple_CheckExact(o) && 0 <= i && i < PyTuple_GET_SIZE(o)) { + else if (PyTuple_CheckExact(o) && ((0 <= i) & (i < PyTuple_GET_SIZE(o)))) { r = PyTuple_GET_ITEM(o, i); Py_INCREF(r); } @@ -5457,7 +5457,7 @@ setitem_int_utility_code = UtilityCode( proto = """ static INLINE int __Pyx_SetItemInt(PyObject *o, Py_ssize_t i, PyObject *v, int is_unsigned) { int r; - if (PyList_CheckExact(o) && 0 <= i && i < PyList_GET_SIZE(o)) { + if (PyList_CheckExact(o) && (0 <= i & i < PyList_GET_SIZE(o))) { Py_DECREF(PyList_GET_ITEM(o, i)); Py_INCREF(v); PyList_SET_ITEM(o, i, v); -- 2.26.2