Skip to content

Commit 706abbe

Browse files
committed
Update: hash function
1 parent 00a5309 commit 706abbe

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

kaleidoscope/operators/randomizeop.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,14 @@
2424

2525

2626
def _hash(name: str) -> int:
27-
h = 1
27+
"""
28+
Daniel J. Bernstein hash function.
29+
30+
Returns a positive hash value.
31+
"""
32+
h = 5381
2833
for c in name:
29-
h = 31 * h + ord(c)
34+
h = ((h << 5) + h) + ord(c)
3035
return h
3136

3237

0 commit comments

Comments
 (0)