decodeBuf
(hist *history)
| 225 | |
| 226 | // decodeBuf |
| 227 | func (b *blockDec) decodeBuf(hist *history) error { |
| 228 | switch b.Type { |
| 229 | case blockTypeRLE: |
| 230 | if cap(b.dst) < int(b.RLESize) { |
| 231 | if b.lowMem { |
| 232 | b.dst = make([]byte, b.RLESize) |
| 233 | } else { |
| 234 | b.dst = make([]byte, maxCompressedBlockSize) |
| 235 | } |
| 236 | } |
| 237 | b.dst = b.dst[:b.RLESize] |
| 238 | v := b.data[0] |
| 239 | for i := range b.dst { |
| 240 | b.dst[i] = v |
| 241 | } |
| 242 | hist.appendKeep(b.dst) |
| 243 | return nil |
| 244 | case blockTypeRaw: |
| 245 | hist.appendKeep(b.data) |
| 246 | return nil |
| 247 | case blockTypeCompressed: |
| 248 | saved := b.dst |
| 249 | // Append directly to history |
| 250 | if hist.ignoreBuffer == 0 { |
| 251 | b.dst = hist.b |
| 252 | hist.b = nil |
| 253 | } else { |
| 254 | b.dst = b.dst[:0] |
| 255 | } |
| 256 | err := b.decodeCompressed(hist) |
| 257 | if debugDecoder { |
| 258 | println("Decompressed to total", len(b.dst), "bytes, hash:", xxhash.Sum64(b.dst), "error:", err) |
| 259 | } |
| 260 | if hist.ignoreBuffer == 0 { |
| 261 | hist.b = b.dst |
| 262 | b.dst = saved |
| 263 | } else { |
| 264 | hist.appendKeep(b.dst) |
| 265 | } |
| 266 | return err |
| 267 | case blockTypeReserved: |
| 268 | // Used for returning errors. |
| 269 | return b.err |
| 270 | default: |
| 271 | panic("Invalid block type") |
| 272 | } |
| 273 | } |
| 274 | |
| 275 | func (b *blockDec) decodeLiterals(in []byte, hist *history) (remain []byte, err error) { |
| 276 | // There must be at least one byte for Literals_Block_Type and one for Sequences_Section_Header |
no test coverage detected