py/unicode: Clean up utf8 funcs and provide non-utf8 inline versions.
This patch provides inline versions of the utf8 helper functions for the case when unicode is disabled (MICROPY_PY_BUILTINS_STR_UNICODE set to 0). This saves code size. The unichar_charlen function is also renamed to utf8_charlen to match the other utf8 helper functions, and the signature of this function is adjusted for consistency (const char* -> const byte*, mp_uint_t -> size_t).
This commit is contained in:
@@ -346,7 +346,7 @@ STATIC mp_obj_t mp_builtin_ord(mp_obj_t o_in) {
|
||||
const char *str = mp_obj_str_get_data(o_in, &len);
|
||||
#if MICROPY_PY_BUILTINS_STR_UNICODE
|
||||
if (MP_OBJ_IS_STR(o_in)) {
|
||||
len = unichar_charlen(str, len);
|
||||
len = utf8_charlen((const byte*)str, len);
|
||||
if (len == 1) {
|
||||
return mp_obj_new_int(utf8_get_char((const byte*)str));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user