@@ -198,9 +198,7 @@ func (w *huffmanBitWriter) writeBytes(bytes []byte) {
198
198
// numOffsets The number of offsets in offsetEncoding
199
199
// litenc, offenc The literal and offset encoder to use
200
200
func (w * huffmanBitWriter ) generateCodegen (numLiterals int , numOffsets int , litEnc , offEnc * huffmanEncoder ) {
201
- for i := range w .codegenFreq {
202
- w .codegenFreq [i ] = 0
203
- }
201
+ clear (w .codegenFreq [:])
204
202
// Note that we are using codegen both as a temporary variable for holding
205
203
// a copy of the frequencies, and as the place where we put the result.
206
204
// This is fine because the output is always shorter than the input used
@@ -530,12 +528,8 @@ func (w *huffmanBitWriter) writeBlockDynamic(tokens []token, eof bool, input []b
530
528
// and offsetEncoding.
531
529
// The number of literal and offset tokens is returned.
532
530
func (w * huffmanBitWriter ) indexTokens (tokens []token ) (numLiterals , numOffsets int ) {
533
- for i := range w .literalFreq {
534
- w .literalFreq [i ] = 0
535
- }
536
- for i := range w .offsetFreq {
537
- w .offsetFreq [i ] = 0
538
- }
531
+ clear (w .literalFreq )
532
+ clear (w .offsetFreq )
539
533
540
534
for _ , t := range tokens {
541
535
if t < matchType {
@@ -621,9 +615,7 @@ func (w *huffmanBitWriter) writeBlockHuff(eof bool, input []byte) {
621
615
}
622
616
623
617
// Clear histogram
624
- for i := range w .literalFreq {
625
- w .literalFreq [i ] = 0
626
- }
618
+ clear (w .literalFreq )
627
619
628
620
// Add everything as literals
629
621
histogram (input , w .literalFreq )
0 commit comments