]> Cypherpunks repositories - gostls13.git/commitdiff
go/build/constraint: use strings.Builder instead of for { str+=str }
authorAlan Donovan <adonovan@google.com>
Wed, 26 Nov 2025 22:53:04 +0000 (17:53 -0500)
committerAlan Donovan <adonovan@google.com>
Wed, 26 Nov 2025 23:36:05 +0000 (15:36 -0800)
(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>
src/go/build/constraint/expr.go

index 1f39bb20110adf733f91d02652f3de50b911ee94..943c8f3444b3f8af6e47c0740a5286a84e7ad2cf 100644 (file)
@@ -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