diff options
| author | Damien George <damien@micropython.org> | 2022-04-08 13:07:25 +1000 |
|---|---|---|
| committer | Damien George <damien@micropython.org> | 2022-04-14 23:52:14 +1000 |
| commit | dfc6c6299c3ce3788412e054b8381d11283eb4a9 (patch) | |
| tree | dd5dcd8195c5f6910f0b3475346f558ef3b42c6f | |
| parent | 9c8a56343fea4e3603dbeeabd1b3a2194f9dca91 (diff) | |
tools/mpy-tool.py: Optimise freezing of empty str and bytes objects.
Signed-off-by: Damien George <damien@micropython.org>
| -rwxr-xr-x | tools/mpy-tool.py | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/tools/mpy-tool.py b/tools/mpy-tool.py index 17dd8704a..6a769f7b4 100755 --- a/tools/mpy-tool.py +++ b/tools/mpy-tool.py @@ -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" |
