diff options
author | Tim Peters <tim.peters@gmail.com> | 2003-02-02 17:33:53 (GMT) |
---|---|---|
committer | Tim Peters <tim.peters@gmail.com> | 2003-02-02 17:33:53 (GMT) |
commit | 1a3b19a6e9ac3e65fd2b648f5f2e04312afe8674 (patch) | |
tree | de14e7f37e51944fd2b711a468cee74a6b21fbc6 /Objects/longobject.c | |
parent | 70b02d79f90cbe6524291b01c4828d37523cde97 (diff) | |
download | cpython-1a3b19a6e9ac3e65fd2b648f5f2e04312afe8674.zip cpython-1a3b19a6e9ac3e65fd2b648f5f2e04312afe8674.tar.gz cpython-1a3b19a6e9ac3e65fd2b648f5f2e04312afe8674.tar.bz2 |
long_from_binary_base(): Sped this a little by computing the # of bits
needed outside the first loop.
Diffstat (limited to 'Objects/longobject.c')
-rw-r--r-- | Objects/longobject.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/Objects/longobject.c b/Objects/longobject.c index 92e95f7..2ccf414 100644 --- a/Objects/longobject.c +++ b/Objects/longobject.c @@ -1126,15 +1126,15 @@ long_from_binary_base(char **str, int base) k = ch - 'A' + 10; if (k < 0 || k >= base) break; - n += bits_per_char; - if (n < 0) { - PyErr_SetString(PyExc_ValueError, - "long string too large to convert"); - return NULL; - } ++p; } *str = p; + n = (p - start) * bits_per_char; + if (n / bits_per_char != p - start) { + PyErr_SetString(PyExc_ValueError, + "long string too large to convert"); + return NULL; + } /* n <- # of Python digits needed, = ceiling(n/SHIFT). */ n = (n + SHIFT - 1) / SHIFT; z = _PyLong_New(n); |