1
0
mirror of https://github.com/golang/go synced 2024-11-18 16:44:43 -07:00

go/ast: using strings.Builder

Change-Id: I05ebaf4e11b5b6ca7d9bbb0b2241def7773b11cc
Reviewed-on: https://go-review.googlesource.com/c/go/+/428138
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Run-TryBot: xie cui <523516579@qq.com>
This commit is contained in:
cuiweixie 2022-09-03 07:06:19 +08:00 committed by Gopher Robot
parent ef69718dd7
commit a8237ba61a
2 changed files with 4 additions and 3 deletions

View File

@ -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]

View File

@ -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)