tools/mpy-tool.py: Optimise freezing of empty str and bytes objects.

Signed-off-by: Damien George <damien@micropython.org>
pull/8504/head
Damien George 2022-04-08 13:07:25 +10:00
rodzic 9c8a56343f
commit dfc6c6299c
1 zmienionych plików z 5 dodań i 0 usunięć

Wyświetl plik

@ -621,6 +621,11 @@ class CompiledModule:
elif obj is Ellipsis:
return "MP_ROM_PTR(&mp_const_ellipsis_obj)"
elif is_str_type(obj) or is_bytes_type(obj):
if len(obj) == 0:
if is_str_type(obj):
return "MP_ROM_QSTR(MP_QSTR_)"
else:
return "MP_ROM_PTR(&mp_const_empty_bytes_obj)"
if is_str_type(obj):
obj = bytes_cons(obj, "utf8")
obj_type = "mp_type_str"