mirror of
https://github.com/python/cpython.git
synced 2025-12-08 18:32:16 +00:00
long_format(): Simplify new code a bit.
This commit is contained in:
parent
8600b47b61
commit
c8a6b9b6d6
1 changed files with 8 additions and 5 deletions
|
|
@ -840,17 +840,20 @@ long_format(PyObject *aa, int base, int addL)
|
||||||
Py_DECREF(str);
|
Py_DECREF(str);
|
||||||
return NULL;
|
return NULL;
|
||||||
})
|
})
|
||||||
while (--ntostore >= 0) {
|
assert(ntostore > 0);
|
||||||
|
do {
|
||||||
digit nextrem = (digit)(rem / base);
|
digit nextrem = (digit)(rem / base);
|
||||||
char c = (char)(rem - nextrem * base);
|
char c = (char)(rem - nextrem * base);
|
||||||
assert(p > PyString_AS_STRING(str));
|
assert(p > PyString_AS_STRING(str));
|
||||||
c += (c < 10) ? '0' : 'A'-10;
|
c += (c < 10) ? '0' : 'A'-10;
|
||||||
*--p = c;
|
*--p = c;
|
||||||
rem = nextrem;
|
rem = nextrem;
|
||||||
if (a->ob_size == 0 && rem == 0)
|
--ntostore;
|
||||||
break; /* skip leading zeroes */
|
/* Termination is a bit delicate: must not
|
||||||
}
|
store leading zeroes, so must get out if
|
||||||
} while (ABS(a->ob_size) != 0);
|
a and rem are both 0 now. */
|
||||||
|
} while (ntostore && (a->ob_size || rem));
|
||||||
|
} while (a->ob_size != 0);
|
||||||
Py_DECREF(a);
|
Py_DECREF(a);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue