]> Cypherpunks repositories - gostls13.git/commitdiff
compress/flate: cancel redundant operations
authorHeisenberg <lziqiang1@gmail.com>
Wed, 22 Jul 2020 00:59:30 +0000 (08:59 +0800)
committerGopher Robot <gobot@golang.org>
Sun, 8 May 2022 17:05:16 +0000 (17:05 +0000)
The assignment operation in the program seems to be redundant, the first judgment will continue to overwrite the previous value.
The subsequent slicing operation will cut all the values without frequency.

Change-Id: Id59fc36dd5bacfde881edaf0d9c1af5348286611
Reviewed-on: https://go-review.googlesource.com/c/go/+/244157
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Joe Tsai <joetsai@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>

src/compress/flate/huffman_code.go

index 07b7827e1af05639c8825963b6fd20d142ca9494..9b64d15e75c1aa31c709f2ff18def76d102f8adc 100644 (file)
@@ -288,11 +288,9 @@ func (h *huffmanEncoder) generate(freq []int32, maxBits int32) {
                        list[count] = literalNode{uint16(i), f}
                        count++
                } else {
-                       list[count] = literalNode{}
                        h.codes[i].len = 0
                }
        }
-       list[len(freq)] = literalNode{}
 
        list = list[:count]
        if count <= 2 {