diff options
author | Tim Peters <tim.peters@gmail.com> | 2002-08-11 17:54:42 (GMT) |
---|---|---|
committer | Tim Peters <tim.peters@gmail.com> | 2002-08-11 17:54:42 (GMT) |
commit | da1a2212c8ddbb0dfb00fc1cb1c04fce4794d9ab (patch) | |
tree | b3564ffb81aff7272513e15a8fa13b22837ebf93 /Objects/intobject.c | |
parent | 45daeb093f070f2460028068e6e64a88c9db9665 (diff) | |
download | cpython-da1a2212c8ddbb0dfb00fc1cb1c04fce4794d9ab.zip cpython-da1a2212c8ddbb0dfb00fc1cb1c04fce4794d9ab.tar.gz cpython-da1a2212c8ddbb0dfb00fc1cb1c04fce4794d9ab.tar.bz2 |
int_lshift(): Simplified/sped overflow-checking.
Diffstat (limited to 'Objects/intobject.c')
-rw-r--r-- | Objects/intobject.c | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/Objects/intobject.c b/Objects/intobject.c index 40f38ba..1d05a63 100644 --- a/Objects/intobject.c +++ b/Objects/intobject.c @@ -675,15 +675,13 @@ int_lshift(PyIntObject *v, PyIntObject *w) return NULL; return PyInt_FromLong(0L); } - c = a < 0 ? ~a : a; - c >>= LONG_BIT - 1 - b; - if (c) { + c = a << b; + if (a != Py_ARITHMETIC_RIGHT_SHIFT(long, c, b)) { if (PyErr_Warn(PyExc_DeprecationWarning, "x<<y losing bits or changing sign " "will return a long in Python 2.4 and up") < 0) return NULL; } - c = (long)((unsigned long)a << b); return PyInt_FromLong(c); } |