mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-30 22:39:58 +02:00
Add hash.XxHash
Also move the non crypto hash funcs into this new package. This is much faster than e.g. MD5, especially for larger inputs: ``` BenchmarkXxHash/xxHash_43-10 9917955 112.2 ns/op 56 B/op 4 allocs/op BenchmarkXxHash/mdb5_43-10 6017239 204.1 ns/op 96 B/op 3 allocs/op BenchmarkXxHash/fnv32a_43-10 14407333 82.30 ns/op 16 B/op 1 allocs/op BenchmarkXxHash/xxHash_4300-10 2916892 409.7 ns/op 56 B/op 4 allocs/op BenchmarkXxHash/mdb5_4300-10 159748 7491 ns/op 4912 B/op 3 allocs/op BenchmarkXxHash/fnv32a_4300-10 218210 5510 ns/op 16 B/op 1 allocs/op ``` Fixes #12635
This commit is contained in:
@@ -25,6 +25,7 @@ import (
|
||||
"hash"
|
||||
"hash/fnv"
|
||||
|
||||
"github.com/gohugoio/hugo/common/hugo"
|
||||
"github.com/spf13/cast"
|
||||
)
|
||||
|
||||
@@ -72,6 +73,7 @@ func (ns *Namespace) SHA256(v any) (string, error) {
|
||||
// FNV32a hashes v using fnv32a algorithm.
|
||||
// <docsmeta>{"newIn": "0.98.0" }</docsmeta>
|
||||
func (ns *Namespace) FNV32a(v any) (int, error) {
|
||||
hugo.Deprecate("crypto.FNV32a", "Use hash.FNV32a.", "v0.129.0")
|
||||
conv, err := cast.ToStringE(v)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
|
Reference in New Issue
Block a user