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

Method init

flate/dict_decoder.go:40–57  ·  view source on GitHub ↗

init initializes dictDecoder to have a sliding window dictionary of the given size. If a preset dict is provided, it will initialize the dictionary with the contents of dict.

(size int, dict []byte)

Source from the content-addressed store, hash-verified

38// size. If a preset dict is provided, it will initialize the dictionary with
39// the contents of dict.
40func (dd *dictDecoder) init(size int, dict []byte) {
41 *dd = dictDecoder{hist: dd.hist}
42
43 if cap(dd.hist) < size {
44 dd.hist = make([]byte, size)
45 }
46 dd.hist = dd.hist[:size]
47
48 if len(dict) > len(dd.hist) {
49 dict = dict[len(dict)-len(dd.hist):]
50 }
51 dd.wrPos = copy(dd.hist, dict)
52 if dd.wrPos == len(dd.hist) {
53 dd.wrPos = 0
54 dd.full = true
55 }
56 dd.rdPos = dd.wrPos
57}
58
59// histSize reports the total amount of historical data in the dictionary.
60func (dd *dictDecoder) histSize() int {

Callers 1

TestDictDecoderFunction · 0.95

Calls

no outgoing calls

Tested by 1

TestDictDecoderFunction · 0.76