]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/asm: use strings.Builder
authorcuiweixie <cuiweixie@gmail.com>
Sun, 4 Sep 2022 11:55:43 +0000 (19:55 +0800)
committerGopher Robot <gobot@golang.org>
Thu, 8 Sep 2022 14:33:33 +0000 (14:33 +0000)
Change-Id: I2ec419f475f9c5d5ef1d4557cb5862a55a699d9c
Reviewed-on: https://go-review.googlesource.com/c/go/+/428284
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Keith Randall <khr@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

src/cmd/asm/internal/asm/asm.go
src/cmd/asm/internal/asm/endtoend_test.go
src/cmd/asm/internal/asm/pseudo_test.go
src/cmd/asm/internal/lex/lex_test.go

index 050a4f013cce39ab4f5b33d951d326ce54782191..754139c566b56510a44fde474b82ff43f59f38ad 100644 (file)
@@ -5,9 +5,9 @@
 package asm
 
 import (
-       "bytes"
        "fmt"
        "strconv"
+       "strings"
        "text/scanner"
 
        "cmd/asm/internal/arch"
@@ -22,7 +22,7 @@ import (
 
 // TODO: configure the architecture
 
-var testOut *bytes.Buffer // Gathers output when testing.
+var testOut *strings.Builder // Gathers output when testing.
 
 // append adds the Prog to the end of the program-thus-far.
 // If doLabel is set, it also defines the labels collect for this Prog.
index 33a4465af312f25d4f14a834532f9a79fa48b3b2..9660a90ab1e22e6293f3f94d31d904760a14debe 100644 (file)
@@ -34,7 +34,7 @@ func testEndToEnd(t *testing.T, goarch, file string) {
        parser := NewParser(ctxt, architecture, lexer, false)
        pList := new(obj.Plist)
        var ok bool
-       testOut = new(bytes.Buffer) // The assembler writes test output to this buffer.
+       testOut = new(strings.Builder) // The assembler writes test output to this buffer.
        ctxt.Bso = bufio.NewWriter(os.Stdout)
        ctxt.IsAsm = true
        defer ctxt.Bso.Flush()
@@ -277,7 +277,7 @@ func testErrors(t *testing.T, goarch, file string, flags ...string) {
        parser := NewParser(ctxt, architecture, lexer, false)
        pList := new(obj.Plist)
        var ok bool
-       testOut = new(bytes.Buffer) // The assembler writes test output to this buffer.
+       testOut = new(strings.Builder) // The assembler writes test output to this buffer.
        ctxt.Bso = bufio.NewWriter(os.Stdout)
        ctxt.IsAsm = true
        defer ctxt.Bso.Flush()
index fe6ffa60740f8a939da0beaadc40e73796b51474..5e6fcf8dfe887058e0a2a832dae749da9d7d7173 100644 (file)
@@ -5,7 +5,6 @@
 package asm
 
 import (
-       "bytes"
        "strings"
        "testing"
 
@@ -81,7 +80,7 @@ func TestErroneous(t *testing.T) {
        // Note these errors should be independent of the architecture.
        // Just run the test with amd64.
        parser := newParser("amd64")
-       var buf bytes.Buffer
+       var buf strings.Builder
        parser.errorWriter = &buf
 
        for _, cat := range testcats {
index 51679d2fbc71753c742a20f8a1393534a0622015..e8dcf4b22f1218dc3e403d3271ba22945a447e87 100644 (file)
@@ -5,7 +5,6 @@
 package lex
 
 import (
-       "bytes"
        "strings"
        "testing"
        "text/scanner"
@@ -275,7 +274,7 @@ func lines(a ...string) string {
 
 // drain returns a single string representing the processed input tokens.
 func drain(input *Input) string {
-       var buf bytes.Buffer
+       var buf strings.Builder
        for {
                tok := input.Next()
                if tok == scanner.EOF {