From a8237ba61a6014060c5b28b19f7d084000f06fb2 Mon Sep 17 00:00:00 2001 From: cuiweixie Date: Sat, 3 Sep 2022 07:06:19 +0800 Subject: [PATCH] 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> --- src/go/ast/commentmap.go | 3 ++- src/go/ast/scope.go | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) 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) -- 2.50.0