summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorPaul Sokolovsky <pfalcon@users.sourceforge.net>2014-06-07 00:10:10 +0300
committerPaul Sokolovsky <pfalcon@users.sourceforge.net>2014-06-07 00:10:10 +0300
commit180751fbf38c4b6152fc53df3d35b6f9fecac2e7 (patch)
treec7aa52315763e170f5dda25e366c9267feb79e7a
parentd72bc2713aa04ee5239e12a3df17ce9e50985e13 (diff)
parentde09caaa37b1b575660d2f9a22527325662afc41 (diff)
downloadmicropython-180751fbf38c4b6152fc53df3d35b6f9fecac2e7.tar.gz
micropython-180751fbf38c4b6152fc53df3d35b6f9fecac2e7.zip
Merge pull request #670 from Rosuav/stringhash
Bring the C and Python compute_hash functions into consistency
-rw-r--r--py/makeqstrdata.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/py/makeqstrdata.py b/py/makeqstrdata.py
index 2ec5a1fb69..599b936f9e 100644
--- a/py/makeqstrdata.py
+++ b/py/makeqstrdata.py
@@ -27,7 +27,8 @@ def compute_hash(qstr):
hash = 5381
for char in qstr:
hash = (hash * 33) ^ ord(char)
- return hash & 0xffff
+ # Make sure that valid hash is never zero, zero means "hash not computed"
+ return (hash & 0xffff) or 1
def do_work(infiles):
# read the qstrs in from the input files