From bf0d17d1d4f41e5613eb046e8be71a152ab77dee Mon Sep 17 00:00:00 2001 From: Jordan Stephens Date: Wed, 7 Jan 2026 10:44:53 -0800 Subject: [PATCH] fix perfsprint lints concat-loop: string concatenation in a loop --- src/pkg/agent/plugins/compat_oai/generate.go | 6 +++--- src/pkg/cli/client/byoc/gcp/byoc.go | 9 ++++++--- src/pkg/cli/client/byoc/parse.go | 9 ++++++--- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/pkg/agent/plugins/compat_oai/generate.go b/src/pkg/agent/plugins/compat_oai/generate.go index 2cd1e3001..e4faa3680 100644 --- a/src/pkg/agent/plugins/compat_oai/generate.go +++ b/src/pkg/agent/plugins/compat_oai/generate.go @@ -244,11 +244,11 @@ func (g *ModelGenerator) Generate(ctx context.Context, req *ai.ModelRequest, han // concatenateContent concatenates text content into a single string func (g *ModelGenerator) concatenateContent(parts []*ai.Part) string { - content := "" + var b []byte for _, part := range parts { - content += part.Text + b = append(b, part.Text...) } - return content + return string(b) } // generateStream generates a streaming model response diff --git a/src/pkg/cli/client/byoc/gcp/byoc.go b/src/pkg/cli/client/byoc/gcp/byoc.go index b2eaa3893..56a6d1011 100644 --- a/src/pkg/cli/client/byoc/gcp/byoc.go +++ b/src/pkg/cli/client/byoc/gcp/byoc.go @@ -842,15 +842,18 @@ func LogEntryToString(logEntry *loggingpb.LogEntry) (string, string, error) { } func LogEntriesToString(logEntries []*loggingpb.LogEntry) string { - result := "" + var sb strings.Builder for _, logEntry := range logEntries { logTimestamp, msg, err := LogEntryToString(logEntry) if err != nil { continue } - result += logTimestamp + " " + msg + "\n" + sb.WriteString(logTimestamp) + sb.WriteString(" ") + sb.WriteString(msg) + sb.WriteString("\n") } - return result + return sb.String() } func (b *ByocGcp) query(ctx context.Context, query string) ([]*loggingpb.LogEntry, error) { diff --git a/src/pkg/cli/client/byoc/parse.go b/src/pkg/cli/client/byoc/parse.go index 71c8e1999..62000f378 100644 --- a/src/pkg/cli/client/byoc/parse.go +++ b/src/pkg/cli/client/byoc/parse.go @@ -27,11 +27,14 @@ type PulumiState struct { func (ps PulumiState) String() string { var org, pending string if len(ps.Pending) != 0 { - pending = " (pending" + var b strings.Builder + b.WriteString(" (pending") for _, p := range ps.Pending { - pending += " " + strconv.Quote(p) + b.WriteString(" ") + b.WriteString(strconv.Quote(p)) } - pending += ")" + b.WriteString(")") + pending = b.String() } if ps.DefangOrg != "" { org = " {" + string(ps.DefangOrg) + "}"