gz

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2020 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Deflate

func Deflate(data []byte) []byte

Types

type DeflatePool

type DeflatePool struct {
	// contains filtered or unexported fields
}

DeflatePool manages a pool of flate.Writer flate.NewWriter allocates a lot of memory, so if flate.Writer are needed frequently, it's more efficient to use a pool of them. The pool uses sync.Pool internally.

There is no pool for flate readers, because they implement io.ReadCloser and can't be recycled after closing.

var Pool DeflatePool

func (*DeflatePool) GetWriter

func (pool *DeflatePool) GetWriter(dst io.Writer) (writer *flate.Writer)

GetWriter returns flate.Writer from the pool, or creates a new one with flate.BestCompression if the pool is empty.

func (*DeflatePool) PutWriter

func (pool *DeflatePool) PutWriter(writer *flate.Writer)

PutWriter returns a flate.Writer to the pool that can late be reused via GetWriter. Don't close the writer, Flush will be called before returning it to the pool.

Jump to

Keyboard shortcuts

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