Motivation is performance. These templates are typically very small, so the win is minor, I guess.
"unicode"
"unicode/utf8"
+ "github.com/cespare/xxhash/v2"
"github.com/spf13/afero"
"github.com/jdkato/prose/transform"
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()
c.err = errors.New("resources.PostProcess cannot be used in a deferred template")
return
}
- innerHash := helpers.MD5String(s)
+ innerHash := helpers.XxHashString(s)
deferredID := tpl.HugoDeferredTemplatePrefix + innerHash
c.deferNodes[deferredID] = inner