summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorMark Dickinson <dickinsm@gmail.com>2009-09-28 16:52:40 (GMT)
committerMark Dickinson <dickinsm@gmail.com>2009-09-28 16:52:40 (GMT)
commit71adc9328d593449a7d8d3bff45b09bf87afa59e (patch)
tree55c54fa161e83c108d1e1dca97b26a37875316d3 /Objects
parentb331802f976c85954efbeb7a49f2591951460be2 (diff)
downloadcpython-71adc9328d593449a7d8d3bff45b09bf87afa59e.zip
cpython-71adc9328d593449a7d8d3bff45b09bf87afa59e.tar.gz
cpython-71adc9328d593449a7d8d3bff45b09bf87afa59e.tar.bz2
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).
Diffstat (limited to 'Objects')
-rw-r--r--Objects/longobject.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/Objects/longobject.c b/Objects/longobject.c
index d284b4f..376973e 100644
--- a/Objects/longobject.c
+++ b/Objects/longobject.c
@@ -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;
}