Commit Graph

7 Commits

Author SHA1 Message Date
Sebastiaan van Stijn
a723c0c6ea
pkg/reference: remove deprecated SplitObject
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-28 19:06:30 +02:00
Sebastiaan van Stijn
fec33aa735
pkg/reference: deprecate SplitObject
The behavior of this function is quite counter-intuitive, as it preserves
the delimiter in the result, and its use for external consumers would be
very limited.

Spec.Digest no longer uses this function, and it appears that BuildKit is
currently the only (publicly visible) external consumer of it.

This patch deprecates the function.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-27 22:11:42 +02:00
Sebastiaan van Stijn
a5fce38f31
pkg/reference: Spec.Digest(): inline SplitObject code
Inline the relevant code from SplitObject, as we're only interested
in the digest portion.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-27 12:05:23 +02:00
Sebastiaan van Stijn
42145950bb
pkg/reference: SplitObject: add proper GoDoc
The behavior of this function is quite counter-intuitive, as it preserves
the delimiter in the result. This function should probably have been an
internal function, as its use for external consumers would be very limited,
but let's at least document the (surprising) behavior for those that are
considering to use it.

It appears that BuildKit is currently the only (publicly visible) external
consumer of this function; I am planning to inline its functionality in
Spec.Digest() and to deprecate this function so that it can be removed.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-27 12:05:23 +02:00
Sebastiaan van Stijn
74a6156ac2
pkg/reference: SplitObject: zero allocations
Before / After:

    BenchmarkSplitObject-10        2785656    428.1 ns/op     416 B/op    13 allocs/op
    BenchmarkSplitObjectNew-10    13510520     88.2 ns/op       0 B/op     0 allocs/op

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-27 12:05:10 +02:00
Sebastiaan van Stijn
799bca97f2
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>
2024-06-27 12:04:22 +02:00
Derek McGowan
fdb8a527c9
Move reference to pkg/reference
Signed-off-by: Derek McGowan <derek@mcg.dev>
2024-01-17 09:55:58 -08:00