Skip to content
Snippets Groups Projects
Commit 180751fb authored by Paul Sokolovsky's avatar Paul Sokolovsky
Browse files

Merge pull request #670 from Rosuav/stringhash

Bring the C and Python compute_hash functions into consistency
parents d72bc271 de09caaa
No related branches found
No related tags found
No related merge requests found
...@@ -27,7 +27,8 @@ def compute_hash(qstr): ...@@ -27,7 +27,8 @@ def compute_hash(qstr):
hash = 5381 hash = 5381
for char in qstr: for char in qstr:
hash = (hash * 33) ^ ord(char) 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): def do_work(infiles):
# read the qstrs in from the input files # read the qstrs in from the input files
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment