Commit d474f582 authored by Russ Cox's avatar Russ Cox

compress/flate: do not rename math/bits import

Makes compress/flate work better with cmd/dist bootstrap.

Change-Id: Ifc7d74027367008e82c1d14ec77141830583ba82
Reviewed-on: https://go-review.googlesource.com/111815
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent 9d72e8c6
...@@ -10,7 +10,7 @@ package flate ...@@ -10,7 +10,7 @@ package flate
import ( import (
"bufio" "bufio"
"io" "io"
mathbits "math/bits" "math/bits"
"strconv" "strconv"
"sync" "sync"
) )
...@@ -113,7 +113,7 @@ type huffmanDecoder struct { ...@@ -113,7 +113,7 @@ type huffmanDecoder struct {
// tree (i.e., neither over-subscribed nor under-subscribed). The exception is a // tree (i.e., neither over-subscribed nor under-subscribed). The exception is a
// degenerate case where the tree has only a single symbol with length 1. Empty // degenerate case where the tree has only a single symbol with length 1. Empty
// trees are permitted. // trees are permitted.
func (h *huffmanDecoder) init(bits []int) bool { func (h *huffmanDecoder) init(lengths []int) bool {
// Sanity enables additional runtime tests during Huffman // Sanity enables additional runtime tests during Huffman
// table construction. It's intended to be used during // table construction. It's intended to be used during
// development to supplement the currently ad-hoc unit tests. // development to supplement the currently ad-hoc unit tests.
...@@ -127,7 +127,7 @@ func (h *huffmanDecoder) init(bits []int) bool { ...@@ -127,7 +127,7 @@ func (h *huffmanDecoder) init(bits []int) bool {
// compute min and max length. // compute min and max length.
var count [maxCodeLen]int var count [maxCodeLen]int
var min, max int var min, max int
for _, n := range bits { for _, n := range lengths {
if n == 0 { if n == 0 {
continue continue
} }
...@@ -177,7 +177,7 @@ func (h *huffmanDecoder) init(bits []int) bool { ...@@ -177,7 +177,7 @@ func (h *huffmanDecoder) init(bits []int) bool {
link := nextcode[huffmanChunkBits+1] >> 1 link := nextcode[huffmanChunkBits+1] >> 1
h.links = make([][]uint32, huffmanNumChunks-link) h.links = make([][]uint32, huffmanNumChunks-link)
for j := uint(link); j < huffmanNumChunks; j++ { for j := uint(link); j < huffmanNumChunks; j++ {
reverse := int(mathbits.Reverse16(uint16(j))) reverse := int(bits.Reverse16(uint16(j)))
reverse >>= uint(16 - huffmanChunkBits) reverse >>= uint(16 - huffmanChunkBits)
off := j - uint(link) off := j - uint(link)
if sanity && h.chunks[reverse] != 0 { if sanity && h.chunks[reverse] != 0 {
...@@ -188,14 +188,14 @@ func (h *huffmanDecoder) init(bits []int) bool { ...@@ -188,14 +188,14 @@ func (h *huffmanDecoder) init(bits []int) bool {
} }
} }
for i, n := range bits { for i, n := range lengths {
if n == 0 { if n == 0 {
continue continue
} }
code := nextcode[n] code := nextcode[n]
nextcode[n]++ nextcode[n]++
chunk := uint32(i<<huffmanValueShift | n) chunk := uint32(i<<huffmanValueShift | n)
reverse := int(mathbits.Reverse16(uint16(code))) reverse := int(bits.Reverse16(uint16(code)))
reverse >>= uint(16 - n) reverse >>= uint(16 - n)
if n <= huffmanChunkBits { if n <= huffmanChunkBits {
for off := reverse; off < len(h.chunks); off += 1 << uint(n) { for off := reverse; off < len(h.chunks); off += 1 << uint(n) {
...@@ -557,7 +557,7 @@ readLiteral: ...@@ -557,7 +557,7 @@ readLiteral:
return return
} }
} }
dist = int(mathbits.Reverse8(uint8(f.b & 0x1F << 3))) dist = int(bits.Reverse8(uint8(f.b & 0x1F << 3)))
f.b >>= 5 f.b >>= 5
f.nb -= 5 f.nb -= 5
} else { } else {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment