executeSimple handles cases when dictionary is not used.
(seqs []seqVals, hist []byte)
| 239 | |
| 240 | // executeSimple handles cases when dictionary is not used. |
| 241 | func (s *sequenceDecs) executeSimple(seqs []seqVals, hist []byte) error { |
| 242 | // Ensure we have enough output size... |
| 243 | if len(s.out)+s.seqSize+compressedBlockOverAlloc > cap(s.out) { |
| 244 | addBytes := s.seqSize + len(s.out) + compressedBlockOverAlloc |
| 245 | s.out = append(s.out, make([]byte, addBytes)...) |
| 246 | s.out = s.out[:len(s.out)-addBytes] |
| 247 | } |
| 248 | |
| 249 | if debugDecoder { |
| 250 | printf("Execute %d seqs with literals: %d into %d bytes\n", len(seqs), len(s.literals), s.seqSize) |
| 251 | } |
| 252 | |
| 253 | var t = len(s.out) |
| 254 | out := s.out[:t+s.seqSize] |
| 255 | |
| 256 | ctx := executeAsmContext{ |
| 257 | seqs: seqs, |
| 258 | seqIndex: 0, |
| 259 | out: out, |
| 260 | history: hist, |
| 261 | outPosition: t, |
| 262 | litPosition: 0, |
| 263 | literals: s.literals, |
| 264 | windowSize: s.windowSize, |
| 265 | } |
| 266 | // useSafe avoids overwriting the output buffer when the literals slice has |
| 267 | // not been allocated with the required over-allocation slack. |
| 268 | useSafe := cap(s.literals) < len(s.literals)+compressedBlockOverAlloc |
| 269 | |
| 270 | ok := executeSimpleAsm(&ctx, useSafe) |
| 271 | if !ok { |
| 272 | return fmt.Errorf("match offset (%d) bigger than current history (%d)", |
| 273 | seqs[ctx.seqIndex].mo, ctx.outPosition+len(hist)) |
| 274 | } |
| 275 | s.literals = s.literals[ctx.litPosition:] |
| 276 | t = ctx.outPosition |
| 277 | |
| 278 | // Add final literals |
| 279 | copy(out[t:], s.literals) |
| 280 | if debugDecoder { |
| 281 | t += len(s.literals) |
| 282 | if t != len(out) { |
| 283 | panic(fmt.Errorf("length mismatch, want %d, got %d, ss: %d", len(out), t, s.seqSize)) |
| 284 | } |
| 285 | } |
| 286 | s.out = out |
| 287 | |
| 288 | return nil |
| 289 | } |
no test coverage detected