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 }