diff options
author | Damien George <damien.p.george@gmail.com> | 2014-04-14 19:33:23 +0100 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2014-04-14 19:33:23 +0100 |
commit | ad8abd1a9503b61c578881192dd88b7e0f97c8cf (patch) | |
tree | 118d3ff15aca1da127238434b56e646f869e26b6 /py/objstr.c | |
parent | 48a9b3fd1107853aacb4610bf2c40197bea7ba93 (diff) | |
parent | 5904dad842a40a61a9ee588a66a32b38ca434a41 (diff) | |
download | micropython-ad8abd1a9503b61c578881192dd88b7e0f97c8cf.tar.gz micropython-ad8abd1a9503b61c578881192dd88b7e0f97c8cf.zip |
Merge branch 'master' of github.com:micropython/micropython
Diffstat (limited to 'py/objstr.c')
-rw-r--r-- | py/objstr.c | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/py/objstr.c b/py/objstr.c index d933fa5e34..08db2af669 100644 --- a/py/objstr.c +++ b/py/objstr.c @@ -10,13 +10,7 @@ #include "runtime0.h" #include "runtime.h" #include "pfenv.h" - -typedef struct _mp_obj_str_t { - mp_obj_base_t base; - machine_uint_t hash : 16; // XXX here we assume the hash size is 16 bits (it is at the moment; see qstr.c) - machine_uint_t len : 16; // len == number of bytes used in data, alloc = len + 1 because (at the moment) we also append a null byte - const byte *data; -} mp_obj_str_t; +#include "objstr.h" STATIC mp_obj_t str_modulo_format(mp_obj_t pattern, uint n_args, const mp_obj_t *args); const mp_obj_t mp_const_empty_bytes; @@ -1463,7 +1457,8 @@ bool mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2) { } else { GET_STR_HASH(s1, h1); GET_STR_HASH(s2, h2); - if (h1 != h2) { + // If any of hashes is 0, it means it's not valid + if (h1 != 0 && h2 != 0 && h1 != h2) { return false; } GET_STR_DATA_LEN(s1, d1, l1); |