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

Method writeBlockSkip

flate/deflate.go:189–208  ·  view source on GitHub ↗

writeBlockSkip writes the current block and uses the number of tokens to determine if the block should be stored on no matches, or only huffman encoded.

(tok *tokens, index int, eof bool)

Source from the content-addressed store, hash-verified

187// to determine if the block should be stored on no matches, or
188// only huffman encoded.
189func (d *compressor) writeBlockSkip(tok *tokens, index int, eof bool) error {
190 if index > 0 || eof {
191 if d.blockStart <= index {
192 window := d.window[d.blockStart:index]
193 // If we removed less than a 64th of all literals
194 // we huffman compress the block.
195 if int(tok.n) > len(window)-int(tok.n>>6) {
196 d.w.writeBlockHuff(eof, window, d.sync)
197 } else {
198 // Write a dynamic huffman block.
199 d.w.writeBlockDynamic(tok, eof, window, d.sync)
200 }
201 } else {
202 d.w.writeBlock(tok, eof, nil)
203 }
204 d.blockStart = index
205 return d.w.err
206 }
207 return nil
208}
209
210// fillWindow will fill the current window with the supplied
211// dictionary and calculate all hashes.

Callers

nothing calls this directly

Calls 3

writeBlockHuffMethod · 0.80
writeBlockDynamicMethod · 0.80
writeBlockMethod · 0.45

Tested by

no test coverage detected