1
0
mirror of https://github.com/golang/go synced 2024-11-18 12:54:44 -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:
Cuong Manh Le 2022-09-01 00:16:32 +07:00
parent 553f02c6ae
commit 0cf996a9c1

View File

@ -7,6 +7,7 @@ package abt
import (
"fmt"
"strconv"
"strings"
)
const (
@ -326,39 +327,21 @@ func (t *T) Equals(u *T) bool {
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 {
var b string
var b strings.Builder
first := true
for it := t.Iterator(); !it.Done(); {
k, v := it.Next()
if first {
first = false
} else {
b += ("; ")
b.WriteString("; ")
}
b += (strconv.FormatInt(int64(k), 10))
b += (":")
b += fmt.Sprint(v)
b.WriteString(strconv.FormatInt(int64(k), 10))
b.WriteString(":")
b.WriteString(fmt.Sprint(v))
}
return b
return b.String()
}
func (t *node32) equals(u *node32) bool {