Documentation ¶
Overview ¶
Package bytespool provides a simple pool implementation for reusing []byte.
Example ¶
package main import ( "fmt" "strings" "github.com/humuzhu/bytespool" ) func main() { buf := bytespool.Acquire(256) defer bytespool.Release(buf) rd := strings.NewReader("bytespool") n, err := rd.Read(buf) if err != nil { return } name := string(buf[:n]) fmt.Println(name) }
Output: bytespool
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Pool ¶
type Pool interface { // Acquire retrieves a byte slice of the appropriate length from the pool or // allocates a new one. Acquire(n int) []byte // Release adds buf to the pool. Release(buf []byte) }
Pool is a pool to handle cases of reusing byte slice of varying sizes.
Click to show internal directories.
Click to hide internal directories.