d.bestSpeed.reset()
default:
d.chainHead = -1
- for i := range d.hashHead {
- d.hashHead[i] = 0
- }
- for i := range d.hashPrev {
- d.hashPrev[i] = 0
- }
+ clear(d.hashHead[:])
+ clear(d.hashPrev[:])
d.hashOffset = 1
d.index, d.windowEnd = 0, 0
d.blockStart, d.byteAvailable = 0, false
func (e *deflateFast) shiftOffsets() {
if len(e.prev) == 0 {
// We have no history; just clear the table.
- for i := range e.table[:] {
- e.table[i] = tableEntry{}
- }
+ clear(e.table[:])
e.cur = maxMatchOffset + 1
return
}
// numOffsets The number of offsets in offsetEncoding
// litenc, offenc The literal and offset encoder to use
func (w *huffmanBitWriter) generateCodegen(numLiterals int, numOffsets int, litEnc, offEnc *huffmanEncoder) {
- for i := range w.codegenFreq {
- w.codegenFreq[i] = 0
- }
+ clear(w.codegenFreq[:])
// Note that we are using codegen both as a temporary variable for holding
// a copy of the frequencies, and as the place where we put the result.
// This is fine because the output is always shorter than the input used
// and offsetEncoding.
// The number of literal and offset tokens is returned.
func (w *huffmanBitWriter) indexTokens(tokens []token) (numLiterals, numOffsets int) {
- for i := range w.literalFreq {
- w.literalFreq[i] = 0
- }
- for i := range w.offsetFreq {
- w.offsetFreq[i] = 0
- }
+ clear(w.literalFreq)
+ clear(w.offsetFreq)
for _, t := range tokens {
if t < matchType {
}
// Clear histogram
- for i := range w.literalFreq {
- w.literalFreq[i] = 0
- }
+ clear(w.literalFreq)
// Add everything as literals
histogram(input, w.literalFreq)