Style/consistency/nano-optimization nit: replace occurrences of
(high_bits << PyLong_SHIFT) + low_bits with (high_bits << PyLong_SHIFT) | low_bits in Objects/longobject.c. Motivation: - shouldn't unnecessarily mix bit ops with arithmetic ops (style) - this pattern should be spelt the same way thoughout (consistency) - it's very very very slightly faster: no need to worry about carries to the high digit (nano-optimization).
This commit is contained in:
parent
b331802f97
commit
71adc9328d
|
@ -251,7 +251,7 @@ PyLong_AsLong(PyObject *vv)
|
|||
}
|
||||
while (--i >= 0) {
|
||||
prev = x;
|
||||
x = (x << PyLong_SHIFT) + v->ob_digit[i];
|
||||
x = (x << PyLong_SHIFT) | v->ob_digit[i];
|
||||
if ((x >> PyLong_SHIFT) != prev)
|
||||
goto overflow;
|
||||
}
|
||||
|
@ -296,7 +296,7 @@ PyLong_AsSsize_t(PyObject *vv) {
|
|||
}
|
||||
while (--i >= 0) {
|
||||
prev = x;
|
||||
x = (x << PyLong_SHIFT) + v->ob_digit[i];
|
||||
x = (x << PyLong_SHIFT) | v->ob_digit[i];
|
||||
if ((x >> PyLong_SHIFT) != prev)
|
||||
goto overflow;
|
||||
}
|
||||
|
@ -350,7 +350,7 @@ PyLong_AsUnsignedLong(PyObject *vv)
|
|||
}
|
||||
while (--i >= 0) {
|
||||
prev = x;
|
||||
x = (x << PyLong_SHIFT) + v->ob_digit[i];
|
||||
x = (x << PyLong_SHIFT) | v->ob_digit[i];
|
||||
if ((x >> PyLong_SHIFT) != prev) {
|
||||
PyErr_SetString(PyExc_OverflowError,
|
||||
"long int too large to convert");
|
||||
|
@ -386,7 +386,7 @@ PyLong_AsUnsignedLongMask(PyObject *vv)
|
|||
i = -i;
|
||||
}
|
||||
while (--i >= 0) {
|
||||
x = (x << PyLong_SHIFT) + v->ob_digit[i];
|
||||
x = (x << PyLong_SHIFT) | v->ob_digit[i];
|
||||
}
|
||||
return x * sign;
|
||||
}
|
||||
|
@ -1170,7 +1170,7 @@ PyLong_AsUnsignedLongLongMask(PyObject *vv)
|
|||
i = -i;
|
||||
}
|
||||
while (--i >= 0) {
|
||||
x = (x << PyLong_SHIFT) + v->ob_digit[i];
|
||||
x = (x << PyLong_SHIFT) | v->ob_digit[i];
|
||||
}
|
||||
return x * sign;
|
||||
}
|
||||
|
@ -1336,7 +1336,7 @@ inplace_divrem1(digit *pout, digit *pin, Py_ssize_t size, digit n)
|
|||
pout += size;
|
||||
while (--size >= 0) {
|
||||
digit hi;
|
||||
rem = (rem << PyLong_SHIFT) + *--pin;
|
||||
rem = (rem << PyLong_SHIFT) | *--pin;
|
||||
*--pout = hi = (digit)(rem / n);
|
||||
rem -= (twodigits)hi * n;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue