From 58e0f4ac50b3dc732cbfe0d7b04bb41951ac1329 Mon Sep 17 00:00:00 2001 From: Damien George Date: Wed, 23 Sep 2015 10:50:43 +0100 Subject: py: Allocate parse nodes in chunks to reduce fragmentation and RAM use. With this patch parse nodes are allocated sequentially in chunks. This reduces fragmentation of the heap and prevents waste at the end of individually allocated parse nodes. Saves roughly 20% of RAM during parse stage. --- stmhal/pyexec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'stmhal') diff --git a/stmhal/pyexec.c b/stmhal/pyexec.c index aa7e35390..c692933dc 100644 --- a/stmhal/pyexec.c +++ b/stmhal/pyexec.c @@ -64,8 +64,8 @@ STATIC int parse_compile_execute(mp_lexer_t *lex, mp_parse_input_kind_t input_ki if (nlr_push(&nlr) == 0) { // parse and compile the script qstr source_name = lex->source_name; - mp_parse_node_t pn = mp_parse(lex, input_kind); - mp_obj_t module_fun = mp_compile(pn, source_name, MP_EMIT_OPT_NONE, exec_flags & EXEC_FLAG_IS_REPL); + mp_parse_tree_t parse_tree = mp_parse(lex, input_kind); + mp_obj_t module_fun = mp_compile(&parse_tree, source_name, MP_EMIT_OPT_NONE, exec_flags & EXEC_FLAG_IS_REPL); // execute code mp_hal_set_interrupt_char(CHAR_CTRL_C); // allow ctrl-C to interrupt us -- cgit v1.2.3