diff options
author | Cameron Moore <moorereason@gmail.com> | 2018-10-15 20:52:46 -0500 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2018-10-16 08:33:38 +0200 |
commit | 0a3340e95254597bc8a9feb250f2733b7d51edf8 (patch) | |
tree | 4e0b20a2b06769e65c31cc5999a48cb4cae8ac05 | |
parent | 6b21ac3e67cb101255e8c3d9dbf076391a9eed8d (diff) |
resource: Optimize integrity string generation
Remove use of fmt.Sprintf for simple string concatenation. A simple
change for a small perf boost.
```
name old time/op new time/op delta
Integrity-4 525ns ± 2% 268ns ± 2% -48.92% (p=0.000 n=10+10)
name old alloc/op new alloc/op delta
Integrity-4 144B ± 0% 112B ± 0% -22.22% (p=0.000 n=10+10)
name old allocs/op new allocs/op delta
Integrity-4 5.00 ± 0% 3.00 ± 0% -40.00% (p=0.000 n=10+10)
```
-rw-r--r-- | resource/integrity/integrity.go | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/resource/integrity/integrity.go b/resource/integrity/integrity.go index bbb214170..535c06a32 100644 --- a/resource/integrity/integrity.go +++ b/resource/integrity/integrity.go @@ -96,7 +96,7 @@ func (c *Client) Fingerprint(res resource.Resource, algo string) (resource.Resou func integrity(algo string, sum []byte) template.HTMLAttr { encoded := base64.StdEncoding.EncodeToString(sum) - return template.HTMLAttr(fmt.Sprintf("%s-%s", algo, encoded)) + return template.HTMLAttr(algo + "-" + encoded) } func digest(h hash.Hash) ([]byte, error) { |