From b8d55a7604aaffb9645ba1fcff9ea2c84697f7d6 Mon Sep 17 00:00:00 2001 From: Heisenberg Date: Wed, 22 Jul 2020 08:59:30 +0800 Subject: [PATCH] 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 --- src/compress/flate/huffman_code.go | 2 -- 1 file changed, 2 deletions(-) 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 { -- 2.50.0