From 6e628c49cacedd19ade6410551e64cf731728061 Mon Sep 17 00:00:00 2001 From: Damien George Date: Tue, 25 Mar 2014 15:27:15 +0000 Subject: py: Replace naive and teribble hash function with djb2. --- py/makeqstrdata.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'py/makeqstrdata.py') diff --git a/py/makeqstrdata.py b/py/makeqstrdata.py index 934bc43be..741336571 100644 --- a/py/makeqstrdata.py +++ b/py/makeqstrdata.py @@ -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): -- cgit v1.2.3