inline hash function to save extra alloc (#53)

This commit is contained in:
Ignacio Hagopian 2019-08-07 20:52:31 -03:00 committed by James Mills
parent fd179b4a86
commit 1f10b4026d

@ -2,7 +2,6 @@ package internal
import (
"fmt"
"hash/fnv"
"os"
"path/filepath"
"sort"
@ -10,10 +9,18 @@ import (
"strings"
)
const (
offset64 = 14695981039346656037
prime64 = 1099511628211
)
func Hash(key []byte) uint64 {
h := fnv.New64a()
h.Write(key)
return h.Sum64()
var s uint64 = offset64
for _, c := range key {
s ^= uint64(c)
s *= prime64
}
return s
}
func Exists(path string) bool {