diff --git a/src/cmd/go/internal/str/str.go b/src/cmd/go/internal/str/str.go index 975869d760..af7c699972 100644 --- a/src/cmd/go/internal/str/str.go +++ b/src/cmd/go/internal/str/str.go @@ -6,8 +6,8 @@ package str import ( - "bytes" "fmt" + "strings" "unicode" "unicode/utf8" ) @@ -49,7 +49,7 @@ func ToFold(s string) string { return s Slow: - var buf bytes.Buffer + var b strings.Builder for _, r := range s { // SimpleFold(x) cycles to the next equivalent rune > x // or wraps around to smaller values. Iterate until it wraps, @@ -65,9 +65,9 @@ Slow: if 'A' <= r && r <= 'Z' { r += 'a' - 'A' } - buf.WriteRune(r) + b.WriteRune(r) } - return buf.String() + return b.String() } // FoldDup reports a pair of strings from the list that are diff --git a/src/go/internal/gccgoimporter/parser.go b/src/go/internal/gccgoimporter/parser.go index 536083ae08..de9df0bbfb 100644 --- a/src/go/internal/gccgoimporter/parser.go +++ b/src/go/internal/gccgoimporter/parser.go @@ -5,7 +5,6 @@ package gccgoimporter import ( - "bytes" "errors" "fmt" "go/constant" @@ -129,16 +128,16 @@ func (p *parser) parseUnquotedString() string { if p.tok == scanner.EOF { p.error("unexpected EOF") } - var buf bytes.Buffer - buf.WriteString(p.scanner.TokenText()) + var b strings.Builder + b.WriteString(p.scanner.TokenText()) // This loop needs to examine each character before deciding whether to consume it. If we see a semicolon, // we need to let it be consumed by p.next(). for ch := p.scanner.Peek(); ch != '\n' && ch != ';' && ch != scanner.EOF && p.scanner.Whitespace&(1<