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

Method resetBase

zstd/enc_base.go:160–199  ·  view source on GitHub ↗

Reset the encoding table.

(d *dict, singleBlock bool)

Source from the content-addressed store, hash-verified

158
159// Reset the encoding table.
160func (e *fastBase) resetBase(d *dict, singleBlock bool) {
161 if e.blk == nil {
162 e.blk = &blockEnc{lowMem: e.lowMem}
163 e.blk.init()
164 } else {
165 e.blk.reset(nil)
166 }
167 e.blk.initNewEncode()
168 if e.crc == nil {
169 e.crc = xxhash.New()
170 } else {
171 e.crc.Reset()
172 }
173 e.blk.dictLitEnc = nil
174 if d != nil {
175 low := e.lowMem
176 if singleBlock {
177 e.lowMem = true
178 }
179 e.ensureHist(d.ContentSize() + maxCompressedBlockSize)
180 e.lowMem = low
181 }
182
183 // We offset current position so everything will be out of reach.
184 // If above reset line, history will be purged.
185 if e.cur < e.bufferReset {
186 e.cur += e.maxMatchOff + int32(len(e.hist))
187 }
188 e.hist = e.hist[:0]
189 if d != nil {
190 // Set offsets (currently not used)
191 for i, off := range d.offsets {
192 e.blk.recentOffsets[i] = uint32(off)
193 e.blk.prevRecentOffsets[i] = e.blk.recentOffsets[i]
194 }
195 // Transfer litenc.
196 e.blk.dictLitEnc = d.litEnc
197 e.hist = append(e.hist, d.content...)
198 }
199}

Callers 5

ResetMethod · 0.80
ResetMethod · 0.80
ResetMethod · 0.80
ResetMethod · 0.80
ResetMethod · 0.80

Calls 7

ensureHistMethod · 0.95
NewFunction · 0.92
initNewEncodeMethod · 0.80
ContentSizeMethod · 0.80
ResetMethod · 0.65
initMethod · 0.45
resetMethod · 0.45

Tested by

no test coverage detected