buffer

package
v0.0.0-...-449c051 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2016 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

see https://github.com/mailru/easyjson/blob/master/buffer/pool.go

I need Reset() method to test, bu private functions prevents to embed Buffer

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Init

func Init(cfg PoolConfig)

Init sets up a non-default pooling and allocation strategy. Should be run before serialization is done.

Types

type EJBuffer

type EJBuffer struct {

	// Buf is the current chunk that can be used for serialization.
	Buf []byte
	// contains filtered or unexported fields
}

Buffer is a buffer optimized for serialization without extra copying.

func (*EJBuffer) EnsureSpace

func (b *EJBuffer) EnsureSpace(s int)

EnsureSpace makes sure that the current chunk contains at least s free bytes, possibly creating a new chunk.

func (*EJBuffer) Reset

func (b *EJBuffer) Reset()

func (*EJBuffer) Size

func (b *EJBuffer) Size() int

Size computes the size of a buffer by adding sizes of every chunk.

func (*EJBuffer) Write

func (b *EJBuffer) Write(data []byte)

AppendBytes appends a byte slice to buffer.

func (*EJBuffer) WriteByte

func (b *EJBuffer) WriteByte(data byte)

AppendByte appends a single byte to buffer.

func (*EJBuffer) WriteString

func (b *EJBuffer) WriteString(data string)

AppendBytes appends a string to buffer.

type PoolConfig

type PoolConfig struct {
	StartSize  int // Minimum chunk size that is allocated.
	PooledSize int // Minimum chunk size that is reused, reusing chunks too small will result in overhead.
	MaxSize    int // Maximum chunk size that will be allocated.
}

PoolConfig contains configuration for the allocation and reuse strategy.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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