From 4601759bf59e16b860a3f082e9aa4ea78356bf92 Mon Sep 17 00:00:00 2001 From: Damien George Date: Thu, 16 Nov 2017 13:17:51 +1100 Subject: py/objstr: Remove "make_qstr_if_not_already" arg from mp_obj_new_str. This patch simplifies the str creation API to favour the common case of creating a str object that is not forced to be interned. To force interning of a new str the new mp_obj_new_str_via_qstr function is added, and should only be used if warranted. Apart from simplifying the mp_obj_new_str function (and making it have the same signature as mp_obj_new_bytes), this patch also reduces code size by a bit (-16 bytes for bare-arm and roughly -40 bytes on the bare-metal archs). --- py/objstrunicode.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'py/objstrunicode.c') diff --git a/py/objstrunicode.c b/py/objstrunicode.c index 29f7695b7..a1f54b8a2 100644 --- a/py/objstrunicode.c +++ b/py/objstrunicode.c @@ -216,7 +216,7 @@ STATIC mp_obj_t str_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { ++len; } } - return mp_obj_new_str((const char*)s, len, true); // This will create a one-character string + return mp_obj_new_str_via_qstr((const char*)s, len); // This will create a one-character string } else { return MP_OBJ_NULL; // op not supported } @@ -291,7 +291,7 @@ STATIC mp_obj_t str_it_iternext(mp_obj_t self_in) { if (self->cur < len) { const byte *cur = str + self->cur; const byte *end = utf8_next_char(str + self->cur); - mp_obj_t o_out = mp_obj_new_str((const char*)cur, end - cur, true); + mp_obj_t o_out = mp_obj_new_str_via_qstr((const char*)cur, end - cur); self->cur += end - cur; return o_out; } else { -- cgit v1.2.3