Skip to content

Commit b582a78

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

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

kaleidoscope/algorithms/randomize.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,14 @@ def _block_seed(
2626

2727

2828
def _hash(block_id: tuple[int, ...]) -> int:
29-
"""Returns a positive hash value."""
30-
h = 1
29+
"""
30+
Daniel J. Bernstein hash function.
31+
32+
Returns a positive hash value.
33+
"""
34+
h = 5381
3135
for i in block_id:
32-
h = 31 * h + i
36+
h = ((h << 5) + h) + i
3337
return h
3438

3539

0 commit comments

Comments
 (0)