modernize: Use strings.Builder instead of string concatenation

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
This commit is contained in:
Paweł Gronowski
2025-12-15 18:28:50 +01:00
parent 62ed24a87c
commit 71fd582aa2
8 changed files with 37 additions and 30 deletions

View File

@@ -10,6 +10,7 @@ import (
"path/filepath"
"reflect"
"runtime"
"strings"
"github.com/containerd/containerd/v2/pkg/tracing"
"github.com/containerd/log"
@@ -78,7 +79,7 @@ func (l *tarexporter) Load(ctx context.Context, inTar io.ReadCloser, outStream i
}
var parentLinks []parentLink
var imageIDsStr string
var imageIDsStr strings.Builder
var imageRefCount int
for _, m := range manifest {
@@ -142,7 +143,7 @@ func (l *tarexporter) Load(ctx context.Context, inTar io.ReadCloser, outStream i
if err != nil {
return err
}
imageIDsStr += fmt.Sprintf("Loaded image ID: %s\n", imgID)
imageIDsStr.WriteString(fmt.Sprintf("Loaded image ID: %s\n", imgID))
imageRefCount = 0
for _, repoTag := range m.RepoTags {
@@ -172,7 +173,7 @@ func (l *tarexporter) Load(ctx context.Context, inTar io.ReadCloser, outStream i
}
if imageRefCount == 0 {
outStream.Write([]byte(imageIDsStr))
outStream.Write([]byte(imageIDsStr.String()))
}
return nil