]> Cypherpunks repositories - gostls13.git/commitdiff
go/ast: using strings.Builder
authorcuiweixie <cuiweixie@gmail.com>
Fri, 2 Sep 2022 23:06:19 +0000 (07:06 +0800)
committerGopher Robot <gobot@golang.org>
Tue, 6 Sep 2022 21:50:49 +0000 (21:50 +0000)
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>

src/go/ast/commentmap.go
src/go/ast/scope.go

index 9f81493f64219b9c0f7504ecb4d255acbfeae8bf..4196e475d93fa0bb65c34d43256ab38e44663c59 100644 (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]
index 02691f8e5462c34f519bda27b3c965e0a4ee2d51..888221200743c63f3570b61a7c008d07925b156e 100644 (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)