aboutsummaryrefslogtreecommitdiffhomepage
path: root/helpers
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <[email protected]>2024-07-17 12:51:49 +0200
committerBjørn Erik Pedersen <[email protected]>2024-07-17 12:51:49 +0200
commit4d8bfa7f1c21a4b7ece26acdcba3f2e38e54d923 (patch)
tree80070a3432f325b825932247d60186f943bead6e /helpers
parentf0ed91caba9ab962593479e745a0df1a5518c4bf (diff)
downloadhugo-4d8bfa7f1c21a4b7ece26acdcba3f2e38e54d923.tar.gz
hugo-4d8bfa7f1c21a4b7ece26acdcba3f2e38e54d923.zip
tpl: Use xxHash instead of MD5 to hash the deferred templates
Motivation is performance. These templates are typically very small, so the win is minor, I guess.
Diffstat (limited to 'helpers')
-rw-r--r--helpers/general.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/helpers/general.go b/helpers/general.go
index af854041d..fa65265b8 100644
--- a/helpers/general.go
+++ b/helpers/general.go
@@ -27,6 +27,7 @@ import (
"unicode"
"unicode/utf8"
+ "github.com/cespare/xxhash/v2"
"github.com/spf13/afero"
"github.com/jdkato/prose/transform"
@@ -257,6 +258,14 @@ func SliceToLower(s []string) []string {
return l
}
+// XxHashString takes a string and returns its xxHash hash.
+func XxHashString(f string) string {
+ h := xxhash.New()
+ h.WriteString(f)
+ hash := h.Sum(nil)
+ return hex.EncodeToString(hash)
+}
+
// MD5String takes a string and returns its MD5 hash.
func MD5String(f string) string {
h := md5.New()