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

View File

@@ -18,7 +18,6 @@ package reference
import (
"errors"
"fmt"
"net/url"
"path"
"regexp"
@@ -146,10 +145,10 @@ func (r Spec) String() string {
return r.Locator
}
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 `@`