(dst *tokens, src []byte)
| 9 | } |
| 10 | |
| 11 | func (e *fastEncL6) Encode(dst *tokens, src []byte) { |
| 12 | const ( |
| 13 | inputMargin = 12 - 1 |
| 14 | minNonLiteralBlockSize = 1 + 1 + inputMargin |
| 15 | hashShortBytes = 4 |
| 16 | ) |
| 17 | if debugDeflate && e.cur < 0 { |
| 18 | panic(fmt.Sprint("e.cur < 0: ", e.cur)) |
| 19 | } |
| 20 | |
| 21 | // Protect against e.cur wraparound. |
| 22 | for e.cur >= bufferReset { |
| 23 | if len(e.hist) == 0 { |
| 24 | for i := range e.table[:] { |
| 25 | e.table[i] = tableEntry{} |
| 26 | } |
| 27 | for i := range e.bTable[:] { |
| 28 | e.bTable[i] = tableEntryPrev{} |
| 29 | } |
| 30 | e.cur = maxMatchOffset |
| 31 | break |
| 32 | } |
| 33 | // Shift down everything in the table that isn't already too far away. |
| 34 | minOff := e.cur + int32(len(e.hist)) - maxMatchOffset |
| 35 | for i := range e.table[:] { |
| 36 | v := e.table[i].offset |
| 37 | if v <= minOff { |
| 38 | v = 0 |
| 39 | } else { |
| 40 | v = v - e.cur + maxMatchOffset |
| 41 | } |
| 42 | e.table[i].offset = v |
| 43 | } |
| 44 | for i := range e.bTable[:] { |
| 45 | v := e.bTable[i] |
| 46 | if v.Cur.offset <= minOff { |
| 47 | v.Cur.offset = 0 |
| 48 | v.Prev.offset = 0 |
| 49 | } else { |
| 50 | v.Cur.offset = v.Cur.offset - e.cur + maxMatchOffset |
| 51 | if v.Prev.offset <= minOff { |
| 52 | v.Prev.offset = 0 |
| 53 | } else { |
| 54 | v.Prev.offset = v.Prev.offset - e.cur + maxMatchOffset |
| 55 | } |
| 56 | } |
| 57 | e.bTable[i] = v |
| 58 | } |
| 59 | e.cur = maxMatchOffset |
| 60 | } |
| 61 | |
| 62 | s := e.addBlock(src) |
| 63 | |
| 64 | // This check isn't in the Snappy implementation, but there, the caller |
| 65 | // instead of the callee handles this case. |
| 66 | if len(src) < minNonLiteralBlockSize { |
| 67 | // We do not fill the token table. |
| 68 | // This will be picked up by caller. |
nothing calls this directly
no test coverage detected