summaryrefslogtreecommitdiff
path: root/unix
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2014-12-05 19:35:18 +0000
committerDamien George <damien.p.george@gmail.com>2014-12-05 19:35:18 +0000
commita4c52c5a3d19b5527023fedfaae96cb717d03802 (patch)
tree2974180c7270bd13df2e5f080cf951a22c559baa /unix
parent41c07d5b8063d752d2b3e41056bdee3615b54635 (diff)
py: Optimise lexer by exposing lexer type.
mp_lexer_t type is exposed, mp_token_t type is removed, and simple lexer functions (like checking current token kind) are now inlined. This saves 784 bytes ROM on 32-bit unix, 348 bytes on stmhal, and 460 bytes on bare-arm. It also saves a tiny bit of RAM since mp_lexer_t is a bit smaller. Also will run a bit more efficiently.
Diffstat (limited to 'unix')
-rw-r--r--unix/main.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/unix/main.c b/unix/main.c
index 2ade40b18..6733bbdda 100644
--- a/unix/main.c
+++ b/unix/main.c
@@ -114,8 +114,8 @@ STATIC int execute_from_lexer(mp_lexer_t *lex, mp_parse_input_kind_t input_kind,
if (0) {
// just tokenise
- while (!mp_lexer_is_kind(lex, MP_TOKEN_END)) {
- mp_token_show(mp_lexer_cur(lex));
+ while (lex->tok_kind != MP_TOKEN_END) {
+ mp_lexer_show_token(lex);
mp_lexer_to_next(lex);
}
mp_lexer_free(lex);
@@ -132,7 +132,7 @@ STATIC int execute_from_lexer(mp_lexer_t *lex, mp_parse_input_kind_t input_kind,
return 1;
}
- qstr source_name = mp_lexer_source_name(lex);
+ qstr source_name = lex->source_name;
#if MICROPY_PY___FILE__
if (input_kind == MP_PARSE_FILE_INPUT) {
mp_store_global(MP_QSTR___file__, MP_OBJ_NEW_QSTR(source_name));