all: Use new mp_obj_new_str_from_cstr() function.

Use new function mp_obj_new_str_from_cstr() where appropriate.  It
simplifies the code, and makes it smaller too.

Signed-off-by: Jon Foster <jon@jon-foster.co.uk>
This commit is contained in:
Jon Foster
2024-04-01 19:23:49 +01:00
committed by Damien George
parent 289b2dd879
commit 92484d8822
28 changed files with 40 additions and 40 deletions

View File

@@ -127,7 +127,7 @@ MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_network_country_obj, 0, 1, network_count
mp_obj_t mod_network_hostname(size_t n_args, const mp_obj_t *args) {
if (n_args == 0) {
return mp_obj_new_str(mod_network_hostname_data, strlen(mod_network_hostname_data));
return mp_obj_new_str_from_cstr(mod_network_hostname_data);
} else {
size_t len;
const char *str = mp_obj_str_get_data(args[0], &len);