diff options
author | Damien George <damien.p.george@gmail.com> | 2016-09-02 14:42:53 +1000 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2016-09-02 14:49:50 +1000 |
commit | 5f3bda422a18d49fb282a93968b658c568343b7d (patch) | |
tree | 46ccb6bcbde0e30598b48f8db7be175b80141a69 /py/objstr.h | |
parent | f127bef3e41f25eea6da73a52aab2fdc53be2464 (diff) | |
download | micropython-5f3bda422a18d49fb282a93968b658c568343b7d.tar.gz micropython-5f3bda422a18d49fb282a93968b658c568343b7d.zip |
py: If str/bytes hash is 0 then explicitly compute it.
Diffstat (limited to 'py/objstr.h')
-rw-r--r-- | py/objstr.h | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/py/objstr.h b/py/objstr.h index 07929156cb..e14568dac4 100644 --- a/py/objstr.h +++ b/py/objstr.h @@ -39,6 +39,7 @@ typedef struct _mp_obj_str_t { #define MP_DEFINE_STR_OBJ(obj_name, str) mp_obj_str_t obj_name = {{&mp_type_str}, 0, sizeof(str) - 1, (const byte*)str} // use this macro to extract the string hash +// warning: the hash can be 0, meaning invalid, and must then be explicitly computed from the data #define GET_STR_HASH(str_obj_in, str_hash) \ mp_uint_t str_hash; if (MP_OBJ_IS_QSTR(str_obj_in)) \ { str_hash = qstr_hash(MP_OBJ_QSTR_VALUE(str_obj_in)); } else { str_hash = ((mp_obj_str_t*)MP_OBJ_TO_PTR(str_obj_in))->hash; } |