diff options
| author | Damien George <damien@micropython.org> | 2022-06-22 10:37:48 +1000 |
|---|---|---|
| committer | Damien George <damien@micropython.org> | 2022-06-23 11:46:47 +1000 |
| commit | 627ba381545b73a383b9e56a4b29c03ac5914a4d (patch) | |
| tree | d667515be03eb09cda47310bae544ee1e92bee4f /py/parsenum.h | |
| parent | 61ce260ff73b1191a9190c8cac7a7a1bd5b2f274 (diff) | |
py/parsenum: Optimise when building with complex disabled.
To reduce code size when MICROPY_PY_BUILTINS_COMPLEX is disabled.
Signed-off-by: Damien George <damien@micropython.org>
Diffstat (limited to 'py/parsenum.h')
| -rw-r--r-- | py/parsenum.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/py/parsenum.h b/py/parsenum.h index a5bed731d..f444632d2 100644 --- a/py/parsenum.h +++ b/py/parsenum.h @@ -31,7 +31,21 @@ #include "py/obj.h" // these functions raise a SyntaxError if lex!=NULL, else a ValueError + mp_obj_t mp_parse_num_integer(const char *restrict str, size_t len, int base, mp_lexer_t *lex); + +#if MICROPY_PY_BUILTINS_COMPLEX mp_obj_t mp_parse_num_decimal(const char *str, size_t len, bool allow_imag, bool force_complex, mp_lexer_t *lex); +static inline mp_obj_t mp_parse_num_float(const char *str, size_t len, bool allow_imag, mp_lexer_t *lex) { + return mp_parse_num_decimal(str, len, allow_imag, false, lex); +} + +static inline mp_obj_t mp_parse_num_complex(const char *str, size_t len, mp_lexer_t *lex) { + return mp_parse_num_decimal(str, len, true, true, lex); +} +#else +mp_obj_t mp_parse_num_float(const char *str, size_t len, bool allow_imag, mp_lexer_t *lex); +#endif + #endif // MICROPY_INCLUDED_PY_PARSENUM_H |
