From: Heisenberg Date: Wed, 22 Jul 2020 00:59:30 +0000 (+0800) Subject: compress/flate: cancel redundant operations X-Git-Tag: go1.19beta1~363 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=b8d55a7604aaffb9645ba1fcff9ea2c84697f7d6;p=gostls13.git 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 Auto-Submit: Ian Lance Taylor Reviewed-by: Ian Lance Taylor Reviewed-by: David Chase Reviewed-by: Joe Tsai Run-TryBot: Ian Lance Taylor --- diff --git a/src/compress/flate/huffman_code.go b/src/compress/flate/huffman_code.go index 07b7827e1a..9b64d15e75 100644 --- a/src/compress/flate/huffman_code.go +++ b/src/compress/flate/huffman_code.go @@ -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 {