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

Method allocCtable

zstd/fse_encoder.go:81–99  ·  view source on GitHub ↗

allocCtable will allocate tables needed for compression. If existing tables a re big enough, they are simply re-used.

()

Source from the content-addressed store, hash-verified

79// allocCtable will allocate tables needed for compression.
80// If existing tables a re big enough, they are simply re-used.
81func (s *fseEncoder) allocCtable() {
82 tableSize := 1 << s.actualTableLog
83 // get tableSymbol that is big enough.
84 if cap(s.ct.tableSymbol) < tableSize {
85 s.ct.tableSymbol = make([]byte, tableSize)
86 }
87 s.ct.tableSymbol = s.ct.tableSymbol[:tableSize]
88
89 ctSize := tableSize
90 if cap(s.ct.stateTable) < ctSize {
91 s.ct.stateTable = make([]uint16, ctSize)
92 }
93 s.ct.stateTable = s.ct.stateTable[:ctSize]
94
95 if cap(s.ct.symbolTT) < 256 {
96 s.ct.symbolTT = make([]symbolTransform, 256)
97 }
98 s.ct.symbolTT = s.ct.symbolTT[:256]
99}
100
101// buildCTable will populate the compression table so it is ready to be used.
102func (s *fseEncoder) buildCTable() error {

Callers 2

buildCTableMethod · 0.95
setRLEMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected