aboutsummaryrefslogtreecommitdiffhomepage
path: root/tpl
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <[email protected]>2024-07-30 15:47:34 +0200
committerBjørn Erik Pedersen <[email protected]>2024-07-31 16:44:06 +0200
commite67886c038dc79755c14ec77bbeff6605953f9ef (patch)
tree6b36585a55796b5a29d41764175e4d6d82a0d206 /tpl
parentd5eda13cb2e57998210b66e080dc96e95b38e5f0 (diff)
downloadhugo-e67886c038dc79755c14ec77bbeff6605953f9ef.tar.gz
hugo-e67886c038dc79755c14ec77bbeff6605953f9ef.zip
Consolidate all hashing to the common/hashing package
And remove now unsued hashing funcs.
Diffstat (limited to 'tpl')
-rw-r--r--tpl/collections/reflect_helpers.go4
-rw-r--r--tpl/data/resources.go4
-rw-r--r--tpl/partials/partials.go3
-rw-r--r--tpl/templates/templates.go4
-rw-r--r--tpl/transform/unmarshal.go4
5 files changed, 10 insertions, 9 deletions
diff --git a/tpl/collections/reflect_helpers.go b/tpl/collections/reflect_helpers.go
index b1966841d..4b222be15 100644
--- a/tpl/collections/reflect_helpers.go
+++ b/tpl/collections/reflect_helpers.go
@@ -18,8 +18,8 @@ import (
"fmt"
"reflect"
+ "github.com/gohugoio/hugo/common/hashing"
"github.com/gohugoio/hugo/common/types"
- "github.com/gohugoio/hugo/identity"
)
var (
@@ -49,7 +49,7 @@ func normalize(v reflect.Value) any {
k := v.Kind()
switch {
case !v.Type().Comparable():
- return identity.HashUint64(v.Interface())
+ return hashing.HashUint64(v.Interface())
case isNumber(k):
f, err := numberToFloat(v)
if err == nil {
diff --git a/tpl/data/resources.go b/tpl/data/resources.go
index 3a3701d60..9e06c0cce 100644
--- a/tpl/data/resources.go
+++ b/tpl/data/resources.go
@@ -23,7 +23,7 @@ import (
"time"
"github.com/gohugoio/hugo/cache/filecache"
- "github.com/gohugoio/hugo/helpers"
+ "github.com/gohugoio/hugo/common/hashing"
"github.com/spf13/afero"
)
@@ -44,7 +44,7 @@ func (ns *Namespace) getRemote(cache *filecache.Cache, unmarshal func([]byte) (b
var headers bytes.Buffer
req.Header.Write(&headers)
- id := helpers.MD5String(url + headers.String())
+ id := hashing.MD5FromStringHexEncoded(url + headers.String())
var handled bool
var retry bool
diff --git a/tpl/partials/partials.go b/tpl/partials/partials.go
index 8e36e21b9..8de312fd8 100644
--- a/tpl/partials/partials.go
+++ b/tpl/partials/partials.go
@@ -25,6 +25,7 @@ import (
"github.com/bep/lazycache"
+ "github.com/gohugoio/hugo/common/hashing"
"github.com/gohugoio/hugo/identity"
texttemplate "github.com/gohugoio/hugo/tpl/internal/go_templates/texttemplate"
@@ -50,7 +51,7 @@ func (k partialCacheKey) Key() string {
if k.Variants == nil {
return k.Name
}
- return identity.HashString(append([]any{k.Name}, k.Variants...)...)
+ return hashing.HashString(append([]any{k.Name}, k.Variants...)...)
}
func (k partialCacheKey) templateName() string {
diff --git a/tpl/templates/templates.go b/tpl/templates/templates.go
index 91e96ed8e..98b4b4c38 100644
--- a/tpl/templates/templates.go
+++ b/tpl/templates/templates.go
@@ -20,8 +20,8 @@ import (
"strconv"
"sync/atomic"
+ "github.com/gohugoio/hugo/common/hashing"
"github.com/gohugoio/hugo/deps"
- "github.com/gohugoio/hugo/helpers"
"github.com/gohugoio/hugo/tpl"
"github.com/mitchellh/mapstructure"
)
@@ -83,7 +83,7 @@ func (ns *Namespace) DoDefer(ctx context.Context, id string, optsv any) string {
templateName := id
var key string
if opts.Key != "" {
- key = helpers.MD5String(opts.Key)
+ key = hashing.MD5FromStringHexEncoded(opts.Key)
} else {
key = strconv.FormatUint(defferedIDCounter.Add(1), 10)
}
diff --git a/tpl/transform/unmarshal.go b/tpl/transform/unmarshal.go
index dc9029c8d..23b99d91f 100644
--- a/tpl/transform/unmarshal.go
+++ b/tpl/transform/unmarshal.go
@@ -22,11 +22,11 @@ import (
"github.com/gohugoio/hugo/resources"
"github.com/gohugoio/hugo/resources/resource"
+ "github.com/gohugoio/hugo/common/hashing"
"github.com/gohugoio/hugo/common/types"
"github.com/mitchellh/mapstructure"
- "github.com/gohugoio/hugo/helpers"
"github.com/gohugoio/hugo/parser/metadecoders"
"github.com/spf13/cast"
@@ -117,7 +117,7 @@ func (ns *Namespace) Unmarshal(args ...any) (any, error) {
return nil, errors.New("no data to transform")
}
- key := helpers.MD5String(dataStr)
+ key := hashing.MD5FromStringHexEncoded(dataStr)
v, err := ns.cache.GetOrCreate(key, func(string) (*resources.StaleValue[any], error) {
f := decoder.FormatFromContentString(dataStr)