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

Method prepare

huff0/huff0.go:134–176  ·  view source on GitHub ↗
(in []byte)

Source from the content-addressed store, hash-verified

132}
133
134func (s *Scratch) prepare(in []byte) (*Scratch, error) {
135 if len(in) > BlockSizeMax {
136 return nil, ErrTooBig
137 }
138 if s == nil {
139 s = &Scratch{}
140 }
141 if s.MaxSymbolValue == 0 {
142 s.MaxSymbolValue = maxSymbolValue
143 }
144 if s.TableLog == 0 {
145 s.TableLog = tableLogDefault
146 }
147 if s.TableLog > tableLogMax || s.TableLog < minTablelog {
148 return nil, fmt.Errorf(" invalid tableLog %d (%d -> %d)", s.TableLog, minTablelog, tableLogMax)
149 }
150 if s.MaxDecodedSize <= 0 || s.MaxDecodedSize > BlockSizeMax {
151 s.MaxDecodedSize = BlockSizeMax
152 }
153 if s.clearCount && s.maxCount == 0 {
154 for i := range s.count {
155 s.count[i] = 0
156 }
157 s.clearCount = false
158 }
159 if cap(s.Out) == 0 {
160 s.Out = make([]byte, 0, len(in))
161 }
162 s.Out = s.Out[:0]
163
164 s.OutTable = nil
165 s.OutData = nil
166 if cap(s.nodes) < huffNodesLen+1 {
167 s.nodes = make([]nodeElt, 0, huffNodesLen+1)
168 }
169 s.nodes = s.nodes[:0]
170 if s.fse == nil {
171 s.fse = &fse.Scratch{}
172 }
173 s.srcLen = len(in)
174
175 return s, nil
176}
177
178type cTable []cTableEntry
179

Callers 6

BuildCTableMethod · 0.95
AppendTableMethod · 0.95
ReadTableFunction · 0.45
Compress1XFunction · 0.45
Compress4XFunction · 0.45
EstimateSizesFunction · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected