diff --git a/internal/hash/hash.go b/internal/hash/hash.go index 55316c1..9a40e71 100644 --- a/internal/hash/hash.go +++ b/internal/hash/hash.go @@ -1,5 +1,6 @@ package hash +// FNV64a computes FNV-1a hash without allocation. func FNV64a(key string) uint64 { var h uint64 = 14695981039346656037 for i := 0; i < len(key); i++ { @@ -9,6 +10,7 @@ func FNV64a(key string) uint64 { return h } +// FNV64aBytes computes FNV-1a hash from byte slice without allocation. func FNV64aBytes(key []byte) uint64 { var h uint64 = 14695981039346656037 for i := 0; i < len(key); i++ { diff --git a/internal/utils/bytes.go b/internal/utils/bytes.go index 4ca1650..1c09d8a 100644 --- a/internal/utils/bytes.go +++ b/internal/utils/bytes.go @@ -30,6 +30,7 @@ func S2b(s string) []byte { return unsafe.Slice(unsafe.StringData(s), len(s)) } +// BytesContainsFold reports whether b contains subslice, case-insensitively. func BytesContainsFold(b, sub []byte) bool { if len(sub) == 0 { return true