mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
pkg/pools: avoid allocations with (*bufio.Writer).WriteString (mirror)
pkg/pools/pools_test.go:100:18: avoid allocations with (*bufio.Writer).WriteString (mirror)
written, err := writer.Write([]byte("foobar"))
^
pkg/pools/pools_test.go:112:14: avoid allocations with (*bufio.Writer).WriteString (mirror)
if _, err = writer.Write([]byte("barfoo")); err != nil {
^
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
@@ -97,7 +97,7 @@ func TestBufioWriterPoolPutAndGet(t *testing.T) {
|
||||
writer := BufioWriter32KPool.Get(bw)
|
||||
assert.Assert(t, writer != nil)
|
||||
|
||||
written, err := writer.Write([]byte("foobar"))
|
||||
written, err := writer.WriteString("foobar")
|
||||
assert.NilError(t, err)
|
||||
assert.Check(t, is.Equal(6, written))
|
||||
|
||||
@@ -109,7 +109,7 @@ func TestBufioWriterPoolPutAndGet(t *testing.T) {
|
||||
buf.Reset()
|
||||
BufioWriter32KPool.Put(writer)
|
||||
// Try to write something
|
||||
if _, err = writer.Write([]byte("barfoo")); err != nil {
|
||||
if _, err = writer.WriteString("barfoo"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
// If we now try to flush it, it should panic (the writer is nil)
|
||||
|
||||
Reference in New Issue
Block a user