py: Replace naive and teribble hash function with djb2.

This commit is contained in:
Damien George
2014-03-25 15:27:15 +00:00
parent ffb5cfc8d8
commit 6e628c49ca
2 changed files with 7 additions and 5 deletions

View File

@@ -18,9 +18,9 @@ codepoint2name[ord('/')] = 'slash'
# this must match the equivalent function in qstr.c
def compute_hash(qstr):
hash = 0
hash = 5381
for char in qstr:
hash += ord(char)
hash = (hash * 33) ^ ord(char)
return hash & 0xffff
def do_work(infiles):