diff options
| author | shadchin <[email protected]> | 2025-05-23 07:16:06 +0300 |
|---|---|---|
| committer | shadchin <[email protected]> | 2025-05-23 07:32:45 +0300 |
| commit | 1bea05b3f8c2d30248dda30232aee5ce41485141 (patch) | |
| tree | dd29d6ab31ce190712cf21a1a07d7b7053dc7204 /contrib/tools/cython/Cython/Utility/Optimize.c | |
| parent | bb919ff615bff1f8a16a321843cd843497ae83d1 (diff) | |
Update Cython to 3.0.12
commit_hash:96359824bab02082b58bc1c40c68f9462e3ffc3a
Diffstat (limited to 'contrib/tools/cython/Cython/Utility/Optimize.c')
| -rw-r--r-- | contrib/tools/cython/Cython/Utility/Optimize.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/contrib/tools/cython/Cython/Utility/Optimize.c b/contrib/tools/cython/Cython/Utility/Optimize.c index 99e9a8db375..daa936dc83a 100644 --- a/contrib/tools/cython/Cython/Utility/Optimize.c +++ b/contrib/tools/cython/Cython/Utility/Optimize.c @@ -1281,15 +1281,6 @@ static {{c_ret_type}} {{cfunc_name}}(PyObject *op1, PyObject *op2, long intval, PY_LONG_LONG ll{{ival}}, llx; #endif {{endif}} - {{if c_op == '&'}} - // special case for &-ing arbitrarily large numbers with known single digit operands - if ((intval & PyLong_MASK) == intval) { - // Calling PyLong_CompactValue() requires the PyLong value to be compact, we only need the last digit. - long last_digit = (long) __Pyx_PyLong_Digits({{pyval}})[0]; - long result = intval & (likely(__Pyx_PyLong_IsPos({{pyval}})) ? last_digit : (PyLong_MASK - last_digit + 1)); - return PyLong_FromLong(result); - } - {{endif}} // special cases for 0: + - * % / // | ^ & >> << if (unlikely(__Pyx_PyLong_IsZero({{pyval}}))) { {{if order == 'CObj' and c_op in '%/'}} @@ -1312,6 +1303,15 @@ static {{c_ret_type}} {{cfunc_name}}(PyObject *op1, PyObject *op2, long intval, return __Pyx_NewRef(op1); {{endif}} } + {{if c_op == '&'}} + // special case for &-ing arbitrarily large numbers with known single digit operands + if ((intval & PyLong_MASK) == intval) { + // Calling PyLong_CompactValue() requires the PyLong value to be compact, we only need the last digit. + long last_digit = (long) __Pyx_PyLong_Digits({{pyval}})[0]; + long result = intval & (likely(__Pyx_PyLong_IsPos({{pyval}})) ? last_digit : (PyLong_MASK - last_digit + 1)); + return PyLong_FromLong(result); + } + {{endif}} // handle most common case first to avoid indirect branch and optimise branch prediction if (likely(__Pyx_PyLong_IsCompact({{pyval}}))) { {{ival}} = __Pyx_PyLong_CompactValue({{pyval}}); |
