diff options
| author | Damien George | 2017-11-16 13:17:51 +1100 |
|---|---|---|
| committer | Damien George | 2017-11-16 13:17:51 +1100 |
| commit | 4601759bf59e16b860a3f082e9aa4ea78356bf92 (patch) | |
| tree | 138bedf76b8b9155835bbaf935f2c108d8ff3ec0 /extmod | |
| parent | 6bc55b657b900dd92ebb8b4a8c393644a30dd7e6 (diff) | |
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).
Diffstat (limited to 'extmod')
| -rw-r--r-- | extmod/modujson.c | 2 | ||||
| -rw-r--r-- | extmod/modwebrepl.c | 2 | ||||
| -rw-r--r-- | extmod/vfs_fat.c | 2 | ||||
| -rw-r--r-- | extmod/vfs_fat_misc.c | 2 | ||||
| -rw-r--r-- | extmod/vfs_reader.c | 2 |
5 files changed, 5 insertions, 5 deletions
diff --git a/extmod/modujson.c b/extmod/modujson.c index f14682d26..6eeba4ed6 100644 --- a/extmod/modujson.c +++ b/extmod/modujson.c @@ -166,7 +166,7 @@ STATIC mp_obj_t mod_ujson_load(mp_obj_t stream_obj) { goto fail; } S_NEXT(s); - next = mp_obj_new_str(vstr.buf, vstr.len, false); + next = mp_obj_new_str(vstr.buf, vstr.len); break; case '-': case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': { diff --git a/extmod/modwebrepl.c b/extmod/modwebrepl.c index 3aba5c0f1..42b30f5ea 100644 --- a/extmod/modwebrepl.c +++ b/extmod/modwebrepl.c @@ -141,7 +141,7 @@ STATIC void handle_op(mp_obj_webrepl_t *self) { // Handle operations requiring opened file mp_obj_t open_args[2] = { - mp_obj_new_str(self->hdr.fname, strlen(self->hdr.fname), false), + mp_obj_new_str(self->hdr.fname, strlen(self->hdr.fname)), MP_OBJ_NEW_QSTR(MP_QSTR_rb) }; diff --git a/extmod/vfs_fat.c b/extmod/vfs_fat.c index 22346bdf1..9942ddeb5 100644 --- a/extmod/vfs_fat.c +++ b/extmod/vfs_fat.c @@ -197,7 +197,7 @@ STATIC mp_obj_t fat_vfs_getcwd(mp_obj_t vfs_in) { if (res != FR_OK) { mp_raise_OSError(fresult_to_errno_table[res]); } - return mp_obj_new_str(buf, strlen(buf), false); + return mp_obj_new_str(buf, strlen(buf)); } STATIC MP_DEFINE_CONST_FUN_OBJ_1(fat_vfs_getcwd_obj, fat_vfs_getcwd); diff --git a/extmod/vfs_fat_misc.c b/extmod/vfs_fat_misc.c index 9a26b4a2f..1f90ac14c 100644 --- a/extmod/vfs_fat_misc.c +++ b/extmod/vfs_fat_misc.c @@ -57,7 +57,7 @@ STATIC mp_obj_t mp_vfs_fat_ilistdir_it_iternext(mp_obj_t self_in) { // make 3-tuple with info about this entry mp_obj_tuple_t *t = MP_OBJ_TO_PTR(mp_obj_new_tuple(3, NULL)); if (self->is_str) { - t->items[0] = mp_obj_new_str(fn, strlen(fn), false); + t->items[0] = mp_obj_new_str(fn, strlen(fn)); } else { t->items[0] = mp_obj_new_bytes((const byte*)fn, strlen(fn)); } diff --git a/extmod/vfs_reader.c b/extmod/vfs_reader.c index 891098aa1..e1ee45a3c 100644 --- a/extmod/vfs_reader.c +++ b/extmod/vfs_reader.c @@ -71,7 +71,7 @@ STATIC void mp_reader_vfs_close(void *data) { void mp_reader_new_file(mp_reader_t *reader, const char *filename) { mp_reader_vfs_t *rf = m_new_obj(mp_reader_vfs_t); - mp_obj_t arg = mp_obj_new_str(filename, strlen(filename), false); + mp_obj_t arg = mp_obj_new_str(filename, strlen(filename)); rf->file = mp_vfs_open(1, &arg, (mp_map_t*)&mp_const_empty_map); int errcode; rf->len = mp_stream_rw(rf->file, rf->buf, sizeof(rf->buf), &errcode, MP_STREAM_RW_READ | MP_STREAM_RW_ONCE); |
