]> Cypherpunks repositories - gostls13.git/commitdiff
image/jpeg: use strings.Builder
authorcuiweixie <cuiweixie@gmail.com>
Sun, 4 Sep 2022 10:02:06 +0000 (18:02 +0800)
committerGopher Robot <gobot@golang.org>
Tue, 6 Sep 2022 15:49:30 +0000 (15:49 +0000)
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>

src/image/jpeg/dct_test.go
src/image/jpeg/reader_test.go
src/image/jpeg/writer_test.go

index 845e758878934fe67848796ca34e4efb0d43a999..ed5b73d562cbdb9b7e3df2fb8800cc2fa55aa9d7 100644 (file)
@@ -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")
index 6fdb6c44490319f0a482943ba9507d1c1fa99801..02a2eb6509bc4772a441a721d357b29d732d3eb5 100644 (file)
@@ -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++ {
index abd5e323339be1045e68c34812c8e40c86a413f8..341477044a3a008582e2518876e260c7d63354d5 100644 (file)
@@ -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++ {