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:
Sebastiaan van Stijn
2025-02-07 22:14:23 +01:00
parent f0a233bdc3
commit 4e6c91cc56

View File

@@ -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)