From 9fce5434efbdee157536df20008cd3197172d3e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miloslav=20Trma=C4=8D?= Date: Wed, 4 Sep 2024 20:51:04 +0200 Subject: [PATCH] Use slices.Concat where appropriate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Miloslav Trmač --- store.go | 3 ++- utils.go | 5 ++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/store.go b/store.go index bd4da7a468..c6e9c712c8 100644 --- a/store.go +++ b/store.go @@ -9,6 +9,7 @@ import ( "os" "path/filepath" "reflect" + "slices" "strings" "sync" "syscall" @@ -1622,7 +1623,7 @@ func (s *store) CreateImage(id string, names []string, layer, metadata string, i Digest: dataDigest, }) } - namesToAddAfterCreating = dedupeStrings(append(append([]string{}, i.Names...), names...)) + namesToAddAfterCreating = dedupeStrings(slices.Concat(i.Names, names)) break } } diff --git a/utils.go b/utils.go index 5bade6ffe3..d934a7ea7c 100644 --- a/utils.go +++ b/utils.go @@ -2,6 +2,7 @@ package storage import ( "fmt" + "slices" "github.com/containers/storage/types" ) @@ -54,9 +55,7 @@ func applyNameOperation(oldNames []string, opParameters []string, op updateNameO } } case addNames: - result = make([]string, 0, len(opParameters)+len(oldNames)) - result = append(result, opParameters...) - result = append(result, oldNames...) + result = slices.Concat(opParameters, oldNames) default: return result, errInvalidUpdateNameOperation }