From: cuiweixie Date: Fri, 2 Sep 2022 23:06:19 +0000 (+0800) Subject: go/ast: using strings.Builder X-Git-Tag: go1.20rc1~1180 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=a8237ba61a6014060c5b28b19f7d084000f06fb2;p=gostls13.git go/ast: using strings.Builder Change-Id: I05ebaf4e11b5b6ca7d9bbb0b2241def7773b11cc Reviewed-on: https://go-review.googlesource.com/c/go/+/428138 TryBot-Result: Gopher Robot Auto-Submit: Robert Griesemer Reviewed-by: Ian Lance Taylor Reviewed-by: Robert Griesemer Run-TryBot: xie cui <523516579@qq.com> --- diff --git a/src/go/ast/commentmap.go b/src/go/ast/commentmap.go index 9f81493f64..4196e475d9 100644 --- a/src/go/ast/commentmap.go +++ b/src/go/ast/commentmap.go @@ -9,6 +9,7 @@ import ( "fmt" "go/token" "sort" + "strings" ) type byPos []*CommentGroup @@ -311,7 +312,7 @@ func (cmap CommentMap) String() string { } sort.Sort(byInterval(nodes)) - var buf bytes.Buffer + var buf strings.Builder fmt.Fprintln(&buf, "CommentMap {") for _, node := range nodes { comment := cmap[node] diff --git a/src/go/ast/scope.go b/src/go/ast/scope.go index 02691f8e54..8882212007 100644 --- a/src/go/ast/scope.go +++ b/src/go/ast/scope.go @@ -7,9 +7,9 @@ package ast import ( - "bytes" "fmt" "go/token" + "strings" ) // A Scope maintains the set of named language entities declared @@ -46,7 +46,7 @@ func (s *Scope) Insert(obj *Object) (alt *Object) { // Debugging support func (s *Scope) String() string { - var buf bytes.Buffer + var buf strings.Builder fmt.Fprintf(&buf, "scope %p {", s) if s != nil && len(s.Objects) > 0 { fmt.Fprintln(&buf)