diff options
author | Jeff Epler <jepler@unpythonic.net> | 2025-10-02 13:33:25 -0500 |
---|---|---|
committer | Damien George <damien@micropython.org> | 2025-10-04 16:24:45 +1000 |
commit | d921dd6d61be29866e62b923d3e37859829188bd (patch) | |
tree | 36d2ab666fb48411be126d1aa8f28a3cbb2205fd /py | |
parent | 41284577ca389c463a3e69302de8ad0edaf97f24 (diff) |
py/objmodule: Avoid interning a string unnecessarily.
If the lookup of the module name less the leading "u" is going to succeed,
it's already a qstr (because that qstr is the key in
`mp_builtin_extensible_module_map`). So, use a function that will avoid
interning it if it's not already.
For example, if you `import unavailable` it used to intern the string
`navailable`, but now it won't.
Signed-off-by: Jeff Epler <jepler@unpythonic.net>
Diffstat (limited to 'py')
-rw-r--r-- | py/objmodule.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/py/objmodule.c b/py/objmodule.c index 8c26cc55a..2ffa7847f 100644 --- a/py/objmodule.c +++ b/py/objmodule.c @@ -212,7 +212,7 @@ mp_obj_t mp_module_get_builtin(qstr module_name, bool extensible) { if (module_name_str[0] != 'u') { return MP_OBJ_NULL; } - elem = mp_map_lookup((mp_map_t *)&mp_builtin_extensible_module_map, MP_OBJ_NEW_QSTR(qstr_from_strn(module_name_str + 1, module_name_len - 1)), MP_MAP_LOOKUP); + elem = mp_map_lookup((mp_map_t *)&mp_builtin_extensible_module_map, MP_OBJ_NEW_QSTR(qstr_find_strn(module_name_str + 1, module_name_len - 1)), MP_MAP_LOOKUP); #endif if (!elem) { |