package bytebufferpool

Import Path
	github.com/valyala/bytebufferpool (on go.dev)

Dependency Relation
	imports 4 packages, and imported by 4 packages

Involved Source Files bytebuffer.go Package bytebufferpool implements a pool of byte buffers with anti-fragmentation protection. The pool may waste limited amount of memory due to fragmentation. This amount equals to the maximum total size of the byte buffers in concurrent use. pool.go
Package-Level Type Names (total 2)
/* sort by: | */
ByteBuffer provides byte buffer, which can be used for minimizing memory allocations. ByteBuffer may be used with functions appending data to the given []byte slice. See example code for details. Use Get for obtaining an empty byte buffer. B is a byte buffer to use in append-like workloads. See example code for details. Bytes returns b.B, i.e. all the bytes accumulated in the buffer. The purpose of this function is bytes.Buffer compatibility. Len returns the size of the byte buffer. ReadFrom implements io.ReaderFrom. The function appends all the data read from r to b. Reset makes ByteBuffer.B empty. Set sets ByteBuffer.B to p. SetString sets ByteBuffer.B to s. String returns string representation of ByteBuffer.B. Write implements io.Writer - it appends p to ByteBuffer.B WriteByte appends the byte c to the buffer. The purpose of this function is bytes.Buffer compatibility. The function always returns nil. WriteString appends s to ByteBuffer.B. WriteTo implements io.WriterTo. *ByteBuffer : github.com/ChrisTrenkamp/goxpath/tree.Result *ByteBuffer : fmt.Stringer *ByteBuffer : gorm.io/gorm/clause.Writer *ByteBuffer : internal/bisect.Writer *ByteBuffer : io.ByteWriter *ByteBuffer : io.ReaderFrom *ByteBuffer : io.StringWriter *ByteBuffer : io.Writer *ByteBuffer : io.WriterTo func Get() *ByteBuffer func (*Pool).Get() *ByteBuffer func Put(b *ByteBuffer) func (*Pool).Put(b *ByteBuffer)
Pool represents byte buffer pool. Distinct pools may be used for distinct types of byte buffers. Properly determined byte buffer types with their own pools may help reducing memory waste. Get returns new byte buffer with zero length. The byte buffer may be returned to the pool via Put after the use in order to minimize GC overhead. Put releases byte buffer obtained via Get to the pool. The buffer mustn't be accessed after returning to the pool.
Package-Level Functions (total 2)
Get returns an empty byte buffer from the pool. Got byte buffer may be returned to the pool via Put call. This reduces the number of memory allocations required for byte buffer management.
Put returns byte buffer to the pool. ByteBuffer.B mustn't be touched after returning it to the pool. Otherwise data races will occur.