From 5ffda1ddddb1a94d6bd5a421ff510db479f11960 Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Thu, 25 Jul 2024 11:40:32 -0700 Subject: [PATCH] manifest: LayerInfos: preallocate the slice Signed-off-by: Kir Kolyshkin --- manifest/docker_schema2.go | 2 +- manifest/oci.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/manifest/docker_schema2.go b/manifest/docker_schema2.go index 818166834d..7e53f4f54e 100644 --- a/manifest/docker_schema2.go +++ b/manifest/docker_schema2.go @@ -202,7 +202,7 @@ func (m *Schema2) ConfigInfo() types.BlobInfo { // The Digest field is guaranteed to be provided; Size may be -1. // WARNING: The list may contain duplicates, and they are semantically relevant. func (m *Schema2) LayerInfos() []LayerInfo { - blobs := []LayerInfo{} + blobs := make([]LayerInfo, 0, len(m.LayersDescriptors)) for _, layer := range m.LayersDescriptors { blobs = append(blobs, LayerInfo{ BlobInfo: BlobInfoFromSchema2Descriptor(layer), diff --git a/manifest/oci.go b/manifest/oci.go index 497cf476e3..f714574ee9 100644 --- a/manifest/oci.go +++ b/manifest/oci.go @@ -95,7 +95,7 @@ func (m *OCI1) ConfigInfo() types.BlobInfo { // The Digest field is guaranteed to be provided; Size may be -1. // WARNING: The list may contain duplicates, and they are semantically relevant. func (m *OCI1) LayerInfos() []LayerInfo { - blobs := []LayerInfo{} + blobs := make([]LayerInfo, 0, len(m.Layers)) for _, layer := range m.Layers { blobs = append(blobs, LayerInfo{ BlobInfo: BlobInfoFromOCI1Descriptor(layer),