Skip to content

Commit 0c747b7

Browse files
committed
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 <dmitshur@google.com> TryBot-Bypass: Alan Donovan <adonovan@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
1 parent 0f63973 commit 0c747b7

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

‎src/go/build/constraint/expr.go‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -515,18 +515,18 @@ func PlusBuildLines(x Expr) ([]string, error) {
515515
// Prepare the +build lines.
516516
var lines []string
517517
for _, or := range split {
518-
line := "// +build"
518+
var line strings.Builder
519+
line.WriteString("// +build")
519520
for _, and := range or {
520-
clause := ""
521+
line.WriteString(" ")
521522
for i, lit := range and {
522523
if i > 0 {
523-
clause += ","
524+
line.WriteString(",")
524525
}
525-
clause += lit.String()
526+
line.WriteString(lit.String())
526527
}
527-
line += " " + clause
528528
}
529-
lines = append(lines, line)
529+
lines = append(lines, line.String())
530530
}
531531

532532
return lines, nil

0 commit comments

Comments
 (0)