py/objstr: Optimise mp_obj_new_str_from_vstr for known-safe strings.
The new `mp_obj_new_str_from_utf8_vstr` can be used when you know you already have a unicode-safe string. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
This commit is contained in:
committed by
Damien George
parent
88864587f5
commit
3a910b1565
@@ -2256,6 +2256,13 @@ mp_obj_t mp_obj_new_str_from_vstr(vstr_t *vstr) {
|
||||
return mp_obj_new_str_type_from_vstr(&mp_type_str, vstr);
|
||||
}
|
||||
|
||||
#if MICROPY_PY_BUILTINS_STR_UNICODE && MICROPY_PY_BUILTINS_STR_UNICODE_CHECK
|
||||
mp_obj_t mp_obj_new_str_from_utf8_vstr(vstr_t *vstr) {
|
||||
// bypasses utf8_check.
|
||||
return mp_obj_new_str_type_from_vstr(&mp_type_str, vstr);
|
||||
}
|
||||
#endif // MICROPY_PY_BUILTINS_STR_UNICODE && MICROPY_PY_BUILTINS_STR_UNICODE_CHECK
|
||||
|
||||
mp_obj_t mp_obj_new_bytes_from_vstr(vstr_t *vstr) {
|
||||
return mp_obj_new_str_type_from_vstr(&mp_type_bytes, vstr);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user