diff options
| author | cuiweixie <cuiweixie@gmail.com> | 2022-09-04 18:02:06 +0800 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2022-09-06 15:49:30 +0000 |
| commit | c35bc69c97ddde490e640c2b608941c82de65949 (patch) | |
| tree | 8e5850dff4cb7ec9726c6869cb14231391e2e269 /src/image | |
| parent | 07b19bf5ab1160814ffedd448ce65c0eb6e9643a (diff) | |
| download | go-c35bc69c97ddde490e640c2b608941c82de65949.tar.xz | |
image/jpeg: use strings.Builder
Change-Id: I0a51aa9e7800689c123ce3eaf74742a4641b7681
Reviewed-on: https://go-review.googlesource.com/c/go/+/428261
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Diffstat (limited to 'src/image')
| -rw-r--r-- | src/image/jpeg/dct_test.go | 4 | ||||
| -rw-r--r-- | src/image/jpeg/reader_test.go | 2 | ||||
| -rw-r--r-- | src/image/jpeg/writer_test.go | 3 |
3 files changed, 5 insertions, 4 deletions
diff --git a/src/image/jpeg/dct_test.go b/src/image/jpeg/dct_test.go index 845e758878..ed5b73d562 100644 --- a/src/image/jpeg/dct_test.go +++ b/src/image/jpeg/dct_test.go @@ -5,10 +5,10 @@ package jpeg import ( - "bytes" "fmt" "math" "math/rand" + "strings" "testing" ) @@ -181,7 +181,7 @@ func slowIDCT(b *block) { } func (b *block) String() string { - s := bytes.NewBuffer(nil) + s := &strings.Builder{} fmt.Fprintf(s, "{\n") for y := 0; y < 8; y++ { fmt.Fprintf(s, "\t") diff --git a/src/image/jpeg/reader_test.go b/src/image/jpeg/reader_test.go index 6fdb6c4449..02a2eb6509 100644 --- a/src/image/jpeg/reader_test.go +++ b/src/image/jpeg/reader_test.go @@ -177,7 +177,7 @@ func check(bounds image.Rectangle, pix0, pix1 []byte, stride0, stride1 int) erro } func pixString(pix []byte, stride, x, y int) string { - s := bytes.NewBuffer(nil) + s := &strings.Builder{} for j := 0; j < 8; j++ { fmt.Fprintf(s, "\t") for i := 0; i < 8; i++ { diff --git a/src/image/jpeg/writer_test.go b/src/image/jpeg/writer_test.go index abd5e32333..341477044a 100644 --- a/src/image/jpeg/writer_test.go +++ b/src/image/jpeg/writer_test.go @@ -13,6 +13,7 @@ import ( "io" "math/rand" "os" + "strings" "testing" ) @@ -82,7 +83,7 @@ func TestUnscaledQuant(t *testing.T) { } if bad { names := [nQuantIndex]string{"Luminance", "Chrominance"} - buf := &bytes.Buffer{} + buf := &strings.Builder{} for i, name := range names { fmt.Fprintf(buf, "// %s.\n{\n", name) for zig := 0; zig < blockSize; zig++ { |
