
bufpool
Package bufpool provides a shared pool of reusable byte buffers for streaming I/O, reducing GC pressure by replacing per-call allocations in io.Copy with pooled buffers via io.CopyBuffer.
Index
- func Copy(dst io.Writer, src io.Reader) (int64, error)
- func Get() *[]byte
- func GetWriter(w io.Writer) *bufio.Writer
- func Put(b *[]byte)
- func PutWriter(bw *bufio.Writer)
func Copy
Copy works like io.Copy but uses a pooled buffer to avoid per-call allocations. Safe for concurrent use.
func Get
Get returns a pooled buffer. The caller must call Put when done.
func GetWriter
GetWriter returns a pooled bufio.Writer reset to write to w. The caller must call PutWriter when done. Flush before returning the writer to ensure all buffered data reaches the underlying writer.
func Put
Put returns a buffer to the pool for reuse.
func PutWriter
PutWriter resets the writer (discarding any reference to the underlying writer) and returns it to the pool.
Generated by gomarkdoc