py/qstr: Add qstr_from_strn_static() helper function.

Allows an interned string to reference static/ROM data, instead of
allocating it on the GC heap.

Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
Damien George
2022-03-04 10:40:15 +11:00
parent 50637ff239
commit a1c32101ac
2 changed files with 25 additions and 2 deletions

View File

@@ -101,6 +101,9 @@ qstr qstr_find_strn(const char *str, size_t str_len); // returns MP_QSTRnull if
qstr qstr_from_str(const char *str);
qstr qstr_from_strn(const char *str, size_t len);
#if MICROPY_VFS_ROM
qstr qstr_from_strn_static(const char *str, size_t len);
#endif
mp_uint_t qstr_hash(qstr q);
const char *qstr_str(qstr q);