bufpool

package
v0.0.0-...-414a959 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 7, 2017 License: AGPL-3.0 Imports: 2 Imported by: 0

Documentation

Overview

Package bufpool is a freelist for bytes.Buffer objects.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopyBytes

func CopyBytes(buf *bytes.Buffer) []byte

CopyBytes returns a copy of the bytes contained in the buffer. This slice is safe from updates in the underlying buffer, allowing the buffer to be placed back in the free list.

func Get

func Get() *bytes.Buffer

Get returns an initialized bytes.Buffer object. It is like new(bytes.Buffer) except it uses the free list. The caller should call Put when finished with the returned object. Since Buffer.Bytes() returns the buffer's underlying slice, it is not safe for that slice to escape the caller. If the bytes need to escape, CopyBytes should be used.

func Put

func Put(b *bytes.Buffer)

Put resets the buffer and adds it to the freelist.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL