Documentation ¶
Index ¶
- func Put(b *Buffer)
- func ReleaseByteBuffer(bb *Buffer)
- type Buffer
- func (b *Buffer) Bytes() []byte
- func (b *Buffer) Expand(l, c int)
- func (b *Buffer) Len() int
- func (b *Buffer) ReadFrom(r io.Reader) (int64, error)
- func (b *Buffer) Reset()
- func (b *Buffer) Set(p []byte)
- func (b *Buffer) SetString(s string)
- func (b *Buffer) String() string
- func (b *Buffer) Write(p []byte) (int, error)
- func (b *Buffer) WriteByte(c byte) error
- func (b *Buffer) WriteString(s string) (int, error)
- func (b *Buffer) WriteTo(w io.Writer) (int64, error)
- type Pool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Put ¶
func Put(b *Buffer)
Put returns byte buffer to the pool.
Buffer.B mustn't be touched after returning it to the pool. Otherwise data races will occur.
func ReleaseByteBuffer ¶
func ReleaseByteBuffer(bb *Buffer)
Types ¶
type Buffer ¶
type Buffer struct {
Buf []byte
}
func AcquireByteBuffer ¶
func AcquireByteBuffer() *Buffer
func Get ¶
func Get() *Buffer
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.
func (*Buffer) Bytes ¶
Bytes returns b.Buf, i.e. all the bytes accumulated in the buffer.
The purpose of this function is bytes.Buffer compatibility.
func (*Buffer) ReadFrom ¶
ReadFrom implements io.ReaderFrom.
The function appends all the data read from r to b.
func (*Buffer) WriteByte ¶
WriteByte appends the byte c to the buffer.
The purpose of this function is bytes.Buffer compatibility.
The function always returns nil.
func (*Buffer) WriteString ¶
WriteString appends s to Buffer.B.
type Pool ¶
type Pool struct {
// contains filtered or unexported fields
}
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.