Skip to content

Commit d921dd6

Browse files
jeplerdpgeorge
authored andcommitted
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 <[email protected]>
1 parent 4128457 commit d921dd6

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

py/objmodule.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ mp_obj_t mp_module_get_builtin(qstr module_name, bool extensible) {
212212
if (module_name_str[0] != 'u') {
213213
return MP_OBJ_NULL;
214214
}
215-
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);
215+
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);
216216
#endif
217217

218218
if (!elem) {

0 commit comments

Comments
 (0)