Merge pull request #5208 from jepler/small-memory-savings

Small memory savings
This commit is contained in:
microDev 2021-08-26 09:22:14 +05:30 committed by GitHub
commit 5425454341
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 21 additions and 11 deletions

View File

@ -370,7 +370,7 @@ STATIC int pyexec_raw_repl_process_char(int c) {
}
goto reset;
}
mp_hal_stdout_tx_str("raw REPL; CTRL-B to exit\r\n");
serial_write_compressed(translate("raw REPL; CTRL-B to exit\n"));
goto reset;
} else if (c == CHAR_CTRL_B) {
// change to friendly REPL
@ -469,7 +469,7 @@ STATIC int pyexec_friendly_repl_process_char(int c) {
return PYEXEC_FORCED_EXIT;
} else if (ret == CHAR_CTRL_E) {
// paste mode
mp_hal_stdout_tx_str("\r\npaste mode; Ctrl-C to cancel, Ctrl-D to finish\r\n=== ");
serial_write_compressed(translate("\npaste mode; Ctrl-C to cancel, Ctrl-D to finish\n=== "));
vstr_reset(MP_STATE_VM(repl_line));
repl.paste_mode = true;
return 0;
@ -545,7 +545,7 @@ int pyexec_raw_repl(void) {
vstr_init(&line, 32);
raw_repl_reset:
mp_hal_stdout_tx_str("raw REPL; CTRL-B to exit\r\n");
serial_write_compressed(translate("raw REPL; CTRL-B to exit\n"));
for (;;) {
vstr_reset(&line);

View File

@ -35,6 +35,13 @@ msgid ""
"https://github.com/adafruit/circuitpython/issues\n"
msgstr ""
#: lib/utils/pyexec.c
msgid ""
"\n"
"paste mode; Ctrl-C to cancel, Ctrl-D to finish\n"
"=== "
msgstr ""
#: py/obj.c
msgid " File \"%q\""
msgstr ""
@ -3973,6 +3980,10 @@ msgstr ""
msgid "queue overflow"
msgstr ""
#: lib/utils/pyexec.c
msgid "raw REPL; CTRL-B to exit\n"
msgstr ""
#: py/parse.c
msgid "raw f-strings are not implemented"
msgstr ""

5
main.c
View File

@ -212,10 +212,7 @@ STATIC bool maybe_run_list(const char * const * filenames, pyexec_result_t* exec
return false;
}
mp_hal_stdout_tx_str(filename);
const compressed_string_t* compressed = translate(" output:\n");
char decompressed[decompress_length(compressed)];
decompress(compressed, decompressed);
mp_hal_stdout_tx_str(decompressed);
serial_write_compressed(translate(" output:\n"));
pyexec_file(filename, exec_result);
#if CIRCUITPY_ATEXIT
shared_module_atexit_execute(exec_result);

View File

@ -185,11 +185,13 @@ STATIC void gen_instance_print(const mp_print_t *print, mp_obj_t self_in, mp_pri
mp_obj_gen_instance_t *self = MP_OBJ_TO_PTR(self_in);
#if MICROPY_PY_ASYNC_AWAIT
if (self->coroutine_generator) {
mp_printf(print, "<coroutine object '%q' at %p>", mp_obj_fun_get_name(MP_OBJ_FROM_PTR(self->code_state.fun_bc)), self);
return;
mp_printf(print, "<%q object '%q' at %p>", MP_QSTR_coroutine, mp_obj_fun_get_name(MP_OBJ_FROM_PTR(self->code_state.fun_bc)), self);
} else {
mp_printf(print, "<%q object '%q' at %p>", MP_QSTR_generator, mp_obj_fun_get_name(MP_OBJ_FROM_PTR(self->code_state.fun_bc)), self);
}
#endif
#else
mp_printf(print, "<generator object '%q' at %p>", mp_obj_fun_get_name(MP_OBJ_FROM_PTR(self->code_state.fun_bc)), self);
#endif
}
mp_vm_return_kind_t mp_obj_gen_resume(mp_obj_t self_in, mp_obj_t send_value, mp_obj_t throw_value, mp_obj_t *ret_val) {

View File

@ -32,7 +32,7 @@ const mp_obj_traceback_t mp_const_empty_traceback_obj = {{&mp_type_traceback}, 0
STATIC void mp_obj_traceback_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) {
(void)kind;
mp_obj_traceback_t *o = MP_OBJ_TO_PTR(o_in);
mp_printf(print, "<traceback object at 0x%p>", o);
mp_printf(print, "<%q object at %p>", MP_QSTR_traceback, o);
}
const mp_obj_type_t mp_type_traceback = {