MCPcopy
hub / github.com/klauspost/compress / init

Method init

zstd/blockenc.go:37–74  ·  view source on GitHub ↗

init should be used once the block has been created. If called more than once, the effect is the same as calling reset.

()

Source from the content-addressed store, hash-verified

35// init should be used once the block has been created.
36// If called more than once, the effect is the same as calling reset.
37func (b *blockEnc) init() {
38 if b.lowMem {
39 // 1K literals
40 if cap(b.literals) < 1<<10 {
41 b.literals = make([]byte, 0, 1<<10)
42 }
43 const defSeqs = 20
44 if cap(b.sequences) < defSeqs {
45 b.sequences = make([]seq, 0, defSeqs)
46 }
47 // 1K
48 if cap(b.output) < 1<<10 {
49 b.output = make([]byte, 0, 1<<10)
50 }
51 } else {
52 if cap(b.literals) < maxCompressedBlockSize {
53 b.literals = make([]byte, 0, maxCompressedBlockSize)
54 }
55 const defSeqs = 2000
56 if cap(b.sequences) < defSeqs {
57 b.sequences = make([]seq, 0, defSeqs)
58 }
59 if cap(b.output) < maxCompressedBlockSize {
60 b.output = make([]byte, 0, maxCompressedBlockSize)
61 }
62 }
63
64 if b.coders.mlEnc == nil {
65 b.coders.mlEnc = &fseEncoder{}
66 b.coders.mlPrev = &fseEncoder{}
67 b.coders.ofEnc = &fseEncoder{}
68 b.coders.ofPrev = &fseEncoder{}
69 b.coders.llEnc = &fseEncoder{}
70 b.coders.llPrev = &fseEncoder{}
71 }
72 b.litEnc = &huff0.Scratch{WantLogLess: 4}
73 b.reset(nil)
74}
75
76// initNewEncode can be used to reset offsets and encoders to the initial state.
77func (b *blockEnc) initNewEncode() {

Callers 12

BuildDictFunction · 0.95
ResetMethod · 0.45
Test_seqdec_decoderFunction · 0.45
Test_seqdec_executeFunction · 0.45
Test_seqdec_decodeSyncFunction · 0.45
benchmark_seqdec_decodeFunction · 0.45
Benchmark_seqdec_executeFunction · 0.45
resetBasePrefixMethod · 0.45
resetBaseMethod · 0.45
ConvertMethod · 0.45

Calls 1

resetMethod · 0.95

Tested by 7

Test_seqdec_decoderFunction · 0.36
Test_seqdec_executeFunction · 0.36
Test_seqdec_decodeSyncFunction · 0.36
benchmark_seqdec_decodeFunction · 0.36
Benchmark_seqdec_executeFunction · 0.36