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)
| 187 | // to determine if the block should be stored on no matches, or |
| 188 | // only huffman encoded. |
| 189 | func (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. |
nothing calls this directly
no test coverage detected