From: Alan Donovan Date: Wed, 26 Nov 2025 22:53:04 +0000 (-0500) Subject: go/build/constraint: use strings.Builder instead of for { str+=str } X-Git-Tag: go1.26rc1~69 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=0c747b7aa757da0a0a0ac7b2b5834dca84c7c019;p=gostls13.git go/build/constraint: use strings.Builder instead of for { str+=str } (This works around a bug in the stringsbuilder modernizer.) For #76476 Change-Id: I1cb8715fd79c0363cb9c159686eaeb3482c93228 Reviewed-on: https://go-review.googlesource.com/c/go/+/724721 Reviewed-by: Dmitri Shuralyov TryBot-Bypass: Alan Donovan Reviewed-by: Dmitri Shuralyov --- diff --git a/src/go/build/constraint/expr.go b/src/go/build/constraint/expr.go index 1f39bb2011..943c8f3444 100644 --- a/src/go/build/constraint/expr.go +++ b/src/go/build/constraint/expr.go @@ -515,18 +515,18 @@ func PlusBuildLines(x Expr) ([]string, error) { // Prepare the +build lines. var lines []string for _, or := range split { - line := "// +build" + var line strings.Builder + line.WriteString("// +build") for _, and := range or { - clause := "" + line.WriteString(" ") for i, lit := range and { if i > 0 { - clause += "," + line.WriteString(",") } - clause += lit.String() + line.WriteString(lit.String()) } - line += " " + clause } - lines = append(lines, line) + lines = append(lines, line.String()) } return lines, nil