mirror of
https://github.com/golang/go
synced 2024-11-05 17:46:16 -07:00
cmd/compile/internal/abt: use strings.Builder
Since go1.17 is now used for bootstrapping. Change-Id: I5692ff4b38b7d9a279b20662ce5348ff34a2dde6 Reviewed-on: https://go-review.googlesource.com/c/go/+/427134 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Bryan Mills <bcmills@google.com> Reviewed-by: hopehook <hopehook@golangcn.org> Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: David Chase <drchase@google.com>
This commit is contained in:
parent
553f02c6ae
commit
0cf996a9c1
@ -7,6 +7,7 @@ package abt
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -326,39 +327,21 @@ func (t *T) Equals(u *T) bool {
|
|||||||
return t.root.equals(u.root)
|
return t.root.equals(u.root)
|
||||||
}
|
}
|
||||||
|
|
||||||
// This doesn't build with go1.4, sigh
|
|
||||||
// func (t *T) String() string {
|
|
||||||
// var b strings.Builder
|
|
||||||
// first := true
|
|
||||||
// for it := t.Iterator(); !it.IsEmpty(); {
|
|
||||||
// k, v := it.Next()
|
|
||||||
// if first {
|
|
||||||
// first = false
|
|
||||||
// } else {
|
|
||||||
// b.WriteString("; ")
|
|
||||||
// }
|
|
||||||
// b.WriteString(strconv.FormatInt(int64(k), 10))
|
|
||||||
// b.WriteString(":")
|
|
||||||
// b.WriteString(v.String())
|
|
||||||
// }
|
|
||||||
// return b.String()
|
|
||||||
// }
|
|
||||||
|
|
||||||
func (t *T) String() string {
|
func (t *T) String() string {
|
||||||
var b string
|
var b strings.Builder
|
||||||
first := true
|
first := true
|
||||||
for it := t.Iterator(); !it.Done(); {
|
for it := t.Iterator(); !it.Done(); {
|
||||||
k, v := it.Next()
|
k, v := it.Next()
|
||||||
if first {
|
if first {
|
||||||
first = false
|
first = false
|
||||||
} else {
|
} else {
|
||||||
b += ("; ")
|
b.WriteString("; ")
|
||||||
}
|
}
|
||||||
b += (strconv.FormatInt(int64(k), 10))
|
b.WriteString(strconv.FormatInt(int64(k), 10))
|
||||||
b += (":")
|
b.WriteString(":")
|
||||||
b += fmt.Sprint(v)
|
b.WriteString(fmt.Sprint(v))
|
||||||
}
|
}
|
||||||
return b
|
return b.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *node32) equals(u *node32) bool {
|
func (t *node32) equals(u *node32) bool {
|
||||||
|
Loading…
Reference in New Issue
Block a user