pool

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package pool provides a sync.Pool-based byte buffer pool for minimizing allocations during query building. Buffers are pre-allocated with a 256-byte capacity and reused across query construction cycles.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PutBuffer

func PutBuffer(buf *Buffer)

PutBuffer returns a Buffer to the pool after resetting it. The buffer must not be used after being returned.

Types

type Buffer

type Buffer struct {
	B []byte
}

Buffer is a pooled byte buffer for building query strings.

func GetBuffer

func GetBuffer() *Buffer

GetBuffer returns a Buffer from the pool. The returned buffer is empty but may have pre-allocated capacity from a previous use.

func (*Buffer) Bytes

func (b *Buffer) Bytes() []byte

Bytes returns the byte slice of the buffer contents.

func (*Buffer) Len

func (b *Buffer) Len() int

Len returns the number of bytes in the buffer.

func (*Buffer) Reset

func (b *Buffer) Reset()

Reset clears the buffer contents while retaining the underlying capacity.

func (*Buffer) String

func (b *Buffer) String() string

String returns the buffer contents as a string.

func (*Buffer) Write

func (b *Buffer) Write(p []byte) (int, error)

Write appends p to the buffer. It always returns len(p), nil.

func (*Buffer) WriteByte

func (b *Buffer) WriteByte(c byte) error

WriteByte appends a single byte to the buffer.

func (*Buffer) WriteString

func (b *Buffer) WriteString(s string)

WriteString appends a string to the buffer.

Jump to

Keyboard shortcuts

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