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

Method setPrev

zstd/seqenc.go:21–42  ·  view source on GitHub ↗

setPrev will update the previous encoders to the actually used ones and make sure a fresh one is in the main slot.

(ll, ml, of *fseEncoder)

Source from the content-addressed store, hash-verified

19// setPrev will update the previous encoders to the actually used ones
20// and make sure a fresh one is in the main slot.
21func (s *seqCoders) setPrev(ll, ml, of *fseEncoder) {
22 compareSwap := func(used *fseEncoder, current, prev **fseEncoder) {
23 // We used the new one, more current to history and reuse the previous history
24 if *current == used {
25 *prev, *current = *current, *prev
26 c := *current
27 p := *prev
28 c.reUsed = false
29 p.reUsed = true
30 return
31 }
32 if used == *prev {
33 return
34 }
35 // Ensure we cannot reuse by accident
36 prevEnc := *prev
37 prevEnc.symbolLen = 0
38 }
39 compareSwap(ll, &s.llEnc, &s.llPrev)
40 compareSwap(ml, &s.mlEnc, &s.mlPrev)
41 compareSwap(of, &s.ofEnc, &s.ofPrev)
42}
43
44func highBit(val uint32) (n uint32) {
45 return uint32(bits.Len32(val) - 1)

Callers 2

initNewEncodeMethod · 0.80
encodeMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected