aboutsummaryrefslogtreecommitdiff
path: root/internal/hash/hash_func.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/hash/hash_func.go')
-rw-r--r--internal/hash/hash_func.go6
1 files changed, 5 insertions, 1 deletions
diff --git a/internal/hash/hash_func.go b/internal/hash/hash_func.go
index 853412b..41c4fd5 100644
--- a/internal/hash/hash_func.go
+++ b/internal/hash/hash_func.go
@@ -1,9 +1,13 @@
package hash
+// defaultHash is Chris Torek's hash function
func defaultHash(key []byte) uint32 {
var h uint32
for _, v := range key {
- h = (h << 5) + h + uint32(v)
+ h = hash4b(h, v)
}
return h
}
+
+func hash4a(h uint32, v byte) uint32 { return (h << 5) - h + uint32(v) }
+func hash4b(h uint32, v byte) uint32 { return (h << 5) + h + uint32(v) }