summaryrefslogtreecommitdiff
path: root/libpod
diff options
context:
space:
mode:
authorMiloslav Trmač <mitr@redhat.com>2018-07-28 05:23:20 +0200
committerAtomic Bot <atomic-devel@projectatomic.io>2018-08-01 18:22:59 +0000
commitdae620066284c4c8c35d73941dfecdbc00a2b1b6 (patch)
tree96689fc027b8b76cb01e068cca181cb12b8a0eed /libpod
parent83f40de9652712baf84379f3292dc4f4f103ce50 (diff)
downloadpodman-dae620066284c4c8c35d73941dfecdbc00a2b1b6.tar.gz
podman-dae620066284c4c8c35d73941dfecdbc00a2b1b6.tar.bz2
podman-dae620066284c4c8c35d73941dfecdbc00a2b1b6.zip
Use []pullRefName instead of []*pullRefName
We are passing the values, don't really need the pointer sharing semantics, and the structures are small enough, and the arrays short enough, that we very likely lose on the indirect accesses more than we save on quicker copying of the slices when extending them. Value semantics is safer anyway. Should not change behavior. Signed-off-by: Miloslav Trmač <mitr@redhat.com> Closes: #1176 Approved by: rhatdan
Diffstat (limited to 'libpod')
-rw-r--r--libpod/image/pull.go24
-rw-r--r--libpod/image/pull_test.go4
2 files changed, 14 insertions, 14 deletions
diff --git a/libpod/image/pull.go b/libpod/image/pull.go
index 276ccc898..0ecfbacb8 100644
--- a/libpod/image/pull.go
+++ b/libpod/image/pull.go
@@ -62,11 +62,11 @@ type pullRefName struct {
dstName string
}
-func singlePullRefNameGoal(rn *pullRefName) []*pullRefName {
- return []*pullRefName{rn}
+func singlePullRefNameGoal(rn pullRefName) []pullRefName {
+ return []pullRefName{rn}
}
-func getPullRefName(srcRef types.ImageReference, destName string) *pullRefName {
+func getPullRefName(srcRef types.ImageReference, destName string) pullRefName {
imgPart, err := decompose(destName)
if err == nil && !imgPart.hasRegistry {
// If the image doesn't have a registry, set it as the default repo
@@ -79,7 +79,7 @@ func getPullRefName(srcRef types.ImageReference, destName string) *pullRefName {
if srcRef.DockerReference() != nil {
reference = srcRef.DockerReference().String()
}
- return &pullRefName{
+ return pullRefName{
image: destName,
srcRef: srcRef,
dstName: reference,
@@ -87,7 +87,7 @@ func getPullRefName(srcRef types.ImageReference, destName string) *pullRefName {
}
// refNamesFromImageReference returns a list of pullRefName for a single ImageReference, depending on the used transport.
-func refNamesFromImageReference(ctx context.Context, srcRef types.ImageReference, imgName string, sc *types.SystemContext) ([]*pullRefName, error) {
+func refNamesFromImageReference(ctx context.Context, srcRef types.ImageReference, imgName string, sc *types.SystemContext) ([]pullRefName, error) {
// supports pulling from docker-archive, oci, and registries
switch srcRef.Transport().Name() {
case DockerArchive:
@@ -121,7 +121,7 @@ func refNamesFromImageReference(ctx context.Context, srcRef types.ImageReference
}
// Need to load in all the repo tags from the manifest
- res := []*pullRefName{}
+ res := []pullRefName{}
for _, dst := range manifest[0].RepoTags {
pullInfo := getPullRefName(srcRef, dst)
res = append(res, pullInfo)
@@ -262,7 +262,7 @@ func hasShaInInputName(inputName string) bool {
// refNamesFromPossiblyUnqualifiedName looks at a decomposed image and determines the possible
// image names to try pulling in combination with the registries.conf file as well
-func refNamesFromPossiblyUnqualifiedName(inputName string) ([]*pullRefName, error) {
+func refNamesFromPossiblyUnqualifiedName(inputName string) ([]pullRefName, error) {
decomposedImage, err := decompose(inputName)
if err != nil {
return nil, err
@@ -287,14 +287,14 @@ func refNamesFromPossiblyUnqualifiedName(inputName string) ([]*pullRefName, erro
} else {
ps.dstName = ps.image
}
- return singlePullRefNameGoal(&ps), nil
+ return singlePullRefNameGoal(ps), nil
}
searchRegistries, err := registries.GetRegistries()
if err != nil {
return nil, err
}
- var pullNames []*pullRefName
+ var pullNames []pullRefName
for _, registry := range searchRegistries {
decomposedImage.registry = registry
imageName := decomposedImage.assembleWithTransport()
@@ -310,7 +310,7 @@ func refNamesFromPossiblyUnqualifiedName(inputName string) ([]*pullRefName, erro
srcRef: srcRef,
}
ps.dstName = ps.image
- pullNames = append(pullNames, &ps)
+ pullNames = append(pullNames, ps)
}
return pullNames, nil
}
@@ -325,8 +325,8 @@ func (i *Image) refPairsFromPossiblyUnqualifiedName() ([]*pullRefPair, error) {
return i.imageruntime.pullRefPairsFromRefNames(refNames)
}
-// pullRefPairsFromNames converts a []*pullRefName to []*pullRefPair
-func (ir *Runtime) pullRefPairsFromRefNames(refNames []*pullRefName) ([]*pullRefPair, error) {
+// pullRefPairsFromNames converts a []pullRefName to []*pullRefPair
+func (ir *Runtime) pullRefPairsFromRefNames(refNames []pullRefName) ([]*pullRefPair, error) {
// Here we construct the destination references
res := make([]*pullRefPair, len(refNames))
for i, rn := range refNames {
diff --git a/libpod/image/pull_test.go b/libpod/image/pull_test.go
index 1552d568b..11525539b 100644
--- a/libpod/image/pull_test.go
+++ b/libpod/image/pull_test.go
@@ -73,7 +73,7 @@ func TestGetPullRefName(t *testing.T) {
require.NoError(t, err, c.srcName)
res := getPullRefName(srcRef, c.destName)
- assert.Equal(t, &pullRefName{image: c.expectedImage, srcRef: srcRef, dstName: c.expectedDstName}, res,
+ assert.Equal(t, pullRefName{image: c.expectedImage, srcRef: srcRef, dstName: c.expectedDstName}, res,
fmt.Sprintf("%#v %#v", c.srcName, c.destName))
}
}
@@ -180,7 +180,7 @@ func TestRefNamesFromImageReference(t *testing.T) {
require.NoError(t, err, c.srcName)
require.Len(t, res, len(c.expected), c.srcName)
for i, e := range c.expected {
- assert.Equal(t, &pullRefName{image: e.image, srcRef: srcRef, dstName: e.dstName}, res[i], fmt.Sprintf("%s #%d", c.srcName, i))
+ assert.Equal(t, pullRefName{image: e.image, srcRef: srcRef, dstName: e.dstName}, res[i], fmt.Sprintf("%s #%d", c.srcName, i))
}
}
}