summaryrefslogtreecommitdiffstatshomepage
path: root/py/qstr.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2014-04-14 19:33:23 +0100
committerDamien George <damien.p.george@gmail.com>2014-04-14 19:33:23 +0100
commitad8abd1a9503b61c578881192dd88b7e0f97c8cf (patch)
tree118d3ff15aca1da127238434b56e646f869e26b6 /py/qstr.c
parent48a9b3fd1107853aacb4610bf2c40197bea7ba93 (diff)
parent5904dad842a40a61a9ee588a66a32b38ca434a41 (diff)
downloadmicropython-ad8abd1a9503b61c578881192dd88b7e0f97c8cf.tar.gz
micropython-ad8abd1a9503b61c578881192dd88b7e0f97c8cf.zip
Merge branch 'master' of github.com:micropython/micropython
Diffstat (limited to 'py/qstr.c')
-rw-r--r--py/qstr.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/py/qstr.c b/py/qstr.c
index e4b5c111b5..990ff37727 100644
--- a/py/qstr.c
+++ b/py/qstr.c
@@ -35,7 +35,12 @@ machine_uint_t qstr_compute_hash(const byte *data, uint len) {
for (const byte *top = data + len; data < top; data++) {
hash = ((hash << 5) + hash) ^ (*data); // hash * 33 ^ data
}
- return hash & 0xffff;
+ hash &= 0xffff;
+ // Make sure that valid hash is never zero, zero means "hash not computed"
+ if (hash == 0) {
+ hash++;
+ }
+ return hash;
}
typedef struct _qstr_pool_t {