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/runtime.c | |
parent | f127bef3e41f25eea6da73a52aab2fdc53be2464 (diff) |
py: If str/bytes hash is 0 then explicitly compute it.
Diffstat (limited to 'py/runtime.c')
-rw-r--r-- | py/runtime.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/py/runtime.c b/py/runtime.c index 04b3a34de..48e815f0f 100644 --- a/py/runtime.c +++ b/py/runtime.c @@ -217,6 +217,10 @@ mp_obj_t mp_unary_op(mp_uint_t op, mp_obj_t arg) { } else if (op == MP_UNARY_OP_HASH && MP_OBJ_IS_STR_OR_BYTES(arg)) { // fast path for hashing str/bytes GET_STR_HASH(arg, h); + if (h == 0) { + GET_STR_DATA_LEN(arg, data, len); + h = qstr_compute_hash(data, len); + } return MP_OBJ_NEW_SMALL_INT(h); } else { mp_obj_type_t *type = mp_obj_get_type(arg); |