mirror of
https://github.com/micropython/micropython.git
synced 2026-01-06 12:10:13 +01:00
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:
committed by
Damien George
parent
289b2dd879
commit
92484d8822
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user