]> Cypherpunks repositories - gostls13.git/commitdiff
compress/bzip2: remove dead code in huffman.go
authorJoe Tsai <joetsai@digital-static.net>
Wed, 24 May 2017 20:52:56 +0000 (13:52 -0700)
committerJoe Tsai <thebrokentoaster@gmail.com>
Wed, 24 May 2017 21:56:48 +0000 (21:56 +0000)
The logic performs a series of shifts, which are useless given
that they are followed by an assignment that overrides the
value of the previous computation.

I suspect (but cannot prove) that this is leftover logic from an
original approach that attempted to store both the Huffman code
and the length within the same variable instead of using two
different variables as it currently does now.

Fixes #17949

Change-Id: Ibf6c807c6cef3b28bfdaf2b68d9bc13503ac21b2
Reviewed-on: https://go-review.googlesource.com/44091
Reviewed-by: Ian Lance Taylor <iant@golang.org>
src/compress/bzip2/huffman.go

index 9d574b9bdef3f3bfe782b19ad450c8d13c109a23..dbba9a58b5ae19f9f230f4b4d9a25d776968bc99 100644 (file)
@@ -108,10 +108,6 @@ func newHuffmanTree(lengths []uint8) (huffmanTree, error) {
        codes := huffmanCodes(make([]huffmanCode, len(lengths)))
        for i := len(pairs) - 1; i >= 0; i-- {
                if length > pairs[i].length {
-                       // If the code length decreases we shift in order to
-                       // zero any bits beyond the end of the code.
-                       length >>= 32 - pairs[i].length
-                       length <<= 32 - pairs[i].length
                        length = pairs[i].length
                }
                codes[i].code = code