summaryrefslogtreecommitdiff
path: root/py/builtinimport.c
diff options
context:
space:
mode:
authorDamien George <damien@micropython.org>2022-12-07 14:42:35 +1100
committerDamien George <damien@micropython.org>2022-12-08 12:27:23 +1100
commit2283b6d68fe77b72e7beeb1bf24778834231b190 (patch)
treee7a03f1b759a2312b5b23a04c475f998b4ca20a7 /py/builtinimport.c
parent96c23432f6ef448fdcccdfa6a442d64d7ed06277 (diff)
py: Pass in address to compiled module instead of returning it.
This change makes it so the compiler and persistent code loader take a mp_compiled_module_t* as their last argument, instead of returning this struct. This eliminates a duplicate context variable for all callers of these functions (because the context is now stored in the mp_compiled_module_t by the caller), and also eliminates any confusion about which context to use after the mp_compile_to_raw_code or mp_raw_code_load function returns (because there is now only one context, that stored in mp_compiled_module_t.context). Reduces code size by 16 bytes on ARM Cortex-based ports. Signed-off-by: Damien George <damien@micropython.org>
Diffstat (limited to 'py/builtinimport.c')
-rw-r--r--py/builtinimport.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/py/builtinimport.c b/py/builtinimport.c
index aa31b69db..6f1f7b485 100644
--- a/py/builtinimport.c
+++ b/py/builtinimport.c
@@ -245,7 +245,9 @@ STATIC void do_load(mp_module_context_t *module_obj, vstr_t *file) {
// the correct format and, if so, load and execute the file.
#if MICROPY_HAS_FILE_READER && MICROPY_PERSISTENT_CODE_LOAD
if (file_str[file->len - 3] == 'm') {
- mp_compiled_module_t cm = mp_raw_code_load_file(file_str, module_obj);
+ mp_compiled_module_t cm;
+ cm.context = module_obj;
+ mp_raw_code_load_file(file_str, &cm);
do_execute_raw_code(cm.context, cm.rc, file_str);
return;
}