mirror of
https://github.com/licsber/micropython.git
synced 2024-09-20 09:00:23 +08:00
py/parsenum: Use int instead of mp_int_t for parsing float exponent.
There is no need to use the mp_int_t type which may be 64-bits wide, there is enough bit-width in a normal int to parse reasonable exponents. Using int helps to reduce code size for 64-bit ports, especially nan-boxing builds. (Similarly for the "dig" variable which is now an unsigned int.)
This commit is contained in:
parent
bc6c0b28bf
commit
5efc575067
@ -227,10 +227,10 @@ mp_obj_t mp_parse_num_decimal(const char *str, size_t len, bool allow_imag, bool
|
|||||||
// string should be a decimal number
|
// string should be a decimal number
|
||||||
parse_dec_in_t in = PARSE_DEC_IN_INTG;
|
parse_dec_in_t in = PARSE_DEC_IN_INTG;
|
||||||
bool exp_neg = false;
|
bool exp_neg = false;
|
||||||
mp_int_t exp_val = 0;
|
int exp_val = 0;
|
||||||
mp_int_t exp_extra = 0;
|
int exp_extra = 0;
|
||||||
while (str < top) {
|
while (str < top) {
|
||||||
mp_uint_t dig = *str++;
|
unsigned int dig = *str++;
|
||||||
if ('0' <= dig && dig <= '9') {
|
if ('0' <= dig && dig <= '9') {
|
||||||
dig -= '0';
|
dig -= '0';
|
||||||
if (in == PARSE_DEC_IN_EXP) {
|
if (in == PARSE_DEC_IN_EXP) {
|
||||||
|
Loading…
Reference in New Issue
Block a user