[Python-checkins] CVS: python/dist/src/Objects longobject.c,1.73,1.74
Tim Peters
tim_one@users.sourceforge.net
Tue, 12 Jun 2001 12:17:05 -0700
Update of /cvsroot/python/python/dist/src/Objects
In directory usw-pr-cvs1:/tmp/cvs-serv12556/python/dist/src/Objects
Modified Files:
longobject.c
Log Message:
_PyLong_{As,From}ByteArray: Minor code rearrangement aimed at improving
clarity. Should have no effect visible to callers.
Index: longobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/longobject.c,v
retrieving revision 1.73
retrieving revision 1.74
diff -C2 -r1.73 -r1.74
*** longobject.c 2001/06/12 01:22:22 1.73
--- longobject.c 2001/06/12 19:17:03 1.74
***************
*** 285,289 ****
for (i = 0; i < numsignificantbytes; ++i, p += incr) {
! unsigned int thisbyte = *p;
/* Compute correction for 2's comp, if needed. */
if (is_signed) {
--- 285,289 ----
for (i = 0; i < numsignificantbytes; ++i, p += incr) {
! twodigits thisbyte = *p;
/* Compute correction for 2's comp, if needed. */
if (is_signed) {
***************
*** 365,369 ****
carry = do_twos_comp ? 1 : 0;
for (i = 0; i < ndigits; ++i) {
! unsigned int oldaccumbits = accumbits;
twodigits thisdigit = v->ob_digit[i];
if (do_twos_comp) {
--- 365,369 ----
carry = do_twos_comp ? 1 : 0;
for (i = 0; i < ndigits; ++i) {
! unsigned int numnewbits = SHIFT;
twodigits thisdigit = v->ob_digit[i];
if (do_twos_comp) {
***************
*** 372,379 ****
thisdigit &= MASK;
}
! if (i < ndigits - 1)
! accumbits += SHIFT;
! else {
! /* The most-significant digit may be partly empty. */
twodigits bitmask = 1 << (SHIFT - 1);
twodigits signbit = do_twos_comp << (SHIFT - 1);
--- 372,383 ----
thisdigit &= MASK;
}
! /* Because we're going LSB to MSB, thisdigit is more
! significant than what's already in accum, so needs to be
! prepended to accum. */
! accum |= thisdigit << accumbits;
!
! /* How many new bits did we add? The most-significant digit
! may be (probably is) at least partly empty. */
! if (i == ndigits - 1) {
twodigits bitmask = 1 << (SHIFT - 1);
twodigits signbit = do_twos_comp << (SHIFT - 1);
***************
*** 384,393 ****
signbit >>= 1;
}
! accumbits += SHIFT - nsignbits;
}
! /* Because we're going LSB to MSB, thisdigit is more
! significant than what's already in accum, so needs to be
! prepended to accum. */
! accum |= thisdigit << oldaccumbits;
/* Store as many bytes as possible. */
while (accumbits >= 8) {
--- 388,396 ----
signbit >>= 1;
}
! assert(nsignbits <= SHIFT);
! numnewbits -= nsignbits;
}
! accumbits += numnewbits;
!
/* Store as many bytes as possible. */
while (accumbits >= 8) {