summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorTim Peters <tim.peters@gmail.com>2006-05-25 17:34:03 (GMT)
committerTim Peters <tim.peters@gmail.com>2006-05-25 17:34:03 (GMT)
commitda53afa1b09218c0fb7ce8803cd783a43ee9d319 (patch)
tree55ed99dec4c151821786792c743032ccd72ff4af /Python
parente68955cf3299efa93c95a6638e8e68191c57302b (diff)
downloadcpython-da53afa1b09218c0fb7ce8803cd783a43ee9d319.zip
cpython-da53afa1b09218c0fb7ce8803cd783a43ee9d319.tar.gz
cpython-da53afa1b09218c0fb7ce8803cd783a43ee9d319.tar.bz2
A new table to help string->integer conversion was added yesterday to
both mystrtoul.c and longobject.c. Share the table instead. Also cut its size by 64 entries (they had been used for an inscrutable trick originally, but the code no longer tries to use that trick).
Diffstat (limited to 'Python')
-rw-r--r--Python/mystrtoul.c32
1 files changed, 2 insertions, 30 deletions
diff --git a/Python/mystrtoul.c b/Python/mystrtoul.c
index 272f827..380b37d 100644
--- a/Python/mystrtoul.c
+++ b/Python/mystrtoul.c
@@ -75,34 +75,6 @@ static int digitlimit[] = {
7, 7, 7, 7, 6, 6, 6, 6, 6, 6, /* 20 - 29 */
6, 6, 6, 6, 6, 6, 6}; /* 30 - 36 */
-/* char-to-digit conversion for bases 2-36; all non-digits are 37 */
-static int digitlookup[] = {
- 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37,
- 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37,
- 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37,
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 37, 37, 37, 37, 37, 37,
- 37, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
- 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 37, 37, 37, 37, 37,
- 37, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
- 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 37, 37, 37, 37, 37,
- 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37,
- 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37,
- 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37,
- 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37,
- 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37,
- 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37,
- 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37,
- 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37,
- 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37,
- 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37,
- 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37,
- 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37,
- 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37,
- 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37,
- 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37,
- 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37
-};
-
/*
** strtoul
** This is a general purpose routine for converting
@@ -167,7 +139,7 @@ PyOS_strtoul(register char *str, char **ptr, int base)
ovlimit = digitlimit[base];
/* do the conversion until non-digit character encountered */
- while ((c = digitlookup[Py_CHARMASK(*str)]) < base) {
+ while ((c = _PyLong_DigitValue[Py_CHARMASK(*str)]) < base) {
if (ovlimit > 0) /* no overflow check required */
result = result * base + c;
else { /* requires overflow check */
@@ -204,7 +176,7 @@ PyOS_strtoul(register char *str, char **ptr, int base)
overflowed:
if (ptr) {
/* spool through remaining digit characters */
- while (digitlookup[Py_CHARMASK(*str)] < base)
+ while (_PyLong_DigitValue[Py_CHARMASK(*str)] < base)
++str;
*ptr = str;
}