Source File
blocks.go
Belonging Package
github.com/pierrec/lz4/v4/internal/lz4block
// Package lz4block provides LZ4 BlockSize types and pools of buffers.package lz4blockimportconst (Block64Kb uint32 = 1 << (16 + iota*2)Block256KbBlock1MbBlock4MbBlock8Mb = 2 * Block4Mb)var (BlockPool64K = sync.Pool{New: func() interface{} { return make([]byte, Block64Kb) }}BlockPool256K = sync.Pool{New: func() interface{} { return make([]byte, Block256Kb) }}BlockPool1M = sync.Pool{New: func() interface{} { return make([]byte, Block1Mb) }}BlockPool4M = sync.Pool{New: func() interface{} { return make([]byte, Block4Mb) }}BlockPool8M = sync.Pool{New: func() interface{} { return make([]byte, Block8Mb) }})func ( uint32) BlockSizeIndex {switch {case Block64Kb:return 4case Block256Kb:return 5case Block1Mb:return 6case Block4Mb:return 7case Block8Mb: // only valid in legacy modereturn 3}return 0}func ( uint32) bool {return Index() > 0}type BlockSizeIndex uint8func ( BlockSizeIndex) () bool {switch {case 4, 5, 6, 7:return true}return false}func ( BlockSizeIndex) () []byte {var interface{}switch {case 4:= BlockPool64K.Get()case 5:= BlockPool256K.Get()case 6:= BlockPool1M.Get()case 7:= BlockPool4M.Get()case 3:= BlockPool8M.Get()}return .([]byte)}func ( []byte) {// Safeguard: do not allow invalid buffers.switch := cap(); uint32() {case Block64Kb:BlockPool64K.Put([:])case Block256Kb:BlockPool256K.Put([:])case Block1Mb:BlockPool1M.Put([:])case Block4Mb:BlockPool4M.Put([:])case Block8Mb:BlockPool8M.Put([:])}}type CompressionLevel uint32const Fast CompressionLevel = 0
![]() |
The pages are generated with Golds v0.8.2. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |