pkg/reference: Spec.String(): use string-concatenation instead of sprintf

These were straight concatenations of strings; reduce some allocations by
removing fmt.Sprintf for this.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2024-06-27 11:41:43 +02:00
parent 7a0687f6c8
commit 799bca97f2
No known key found for this signature in database
GPG Key ID: 76698F39D527CE8C

View File

@ -18,7 +18,6 @@ package reference
import ( import (
"errors" "errors"
"fmt"
"net/url" "net/url"
"path" "path"
"regexp" "regexp"
@ -146,10 +145,10 @@ func (r Spec) String() string {
return r.Locator return r.Locator
} }
if r.Object[:1] == "@" { if r.Object[:1] == "@" {
return fmt.Sprintf("%v%v", r.Locator, r.Object) return r.Locator + r.Object
} }
return fmt.Sprintf("%v:%v", r.Locator, r.Object) return r.Locator + ":" + r.Object
} }
// SplitObject provides two parts of the object spec, delimited by an `@` // SplitObject provides two parts of the object spec, delimited by an `@`