1
0
mirror of https://github.com/golang/go synced 2024-11-23 22:00:11 -07:00

compress/flate: cancel redundant operations

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>
This commit is contained in:
Heisenberg 2020-07-22 08:59:30 +08:00 committed by Gopher Robot
parent eed77574d0
commit b8d55a7604

View 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 {