mirror of
https://github.com/golang/go.git
synced 2024-09-29 22:37:06 +00:00
compress/flate: delete unused util functions.
R=rsc CC=golang-dev https://golang.org/cl/5555071
This commit is contained in:
parent
280d85a80b
commit
858f0b4d95
@ -12,6 +12,5 @@ GOFILES=\
|
|||||||
inflate.go\
|
inflate.go\
|
||||||
reverse_bits.go\
|
reverse_bits.go\
|
||||||
token.go\
|
token.go\
|
||||||
util.go\
|
|
||||||
|
|
||||||
include ../../../Make.pkg
|
include ../../../Make.pkg
|
||||||
|
@ -193,15 +193,17 @@ func (w *huffmanBitWriter) writeBytes(bytes []byte) {
|
|||||||
// numLiterals The number of literals in literalEncoding
|
// numLiterals The number of literals in literalEncoding
|
||||||
// numOffsets The number of offsets in offsetEncoding
|
// numOffsets The number of offsets in offsetEncoding
|
||||||
func (w *huffmanBitWriter) generateCodegen(numLiterals int, numOffsets int) {
|
func (w *huffmanBitWriter) generateCodegen(numLiterals int, numOffsets int) {
|
||||||
fillInt32s(w.codegenFreq, 0)
|
for i := range w.codegenFreq {
|
||||||
|
w.codegenFreq[i] = 0
|
||||||
|
}
|
||||||
// Note that we are using codegen both as a temporary variable for holding
|
// Note that we are using codegen both as a temporary variable for holding
|
||||||
// a copy of the frequencies, and as the place where we put the result.
|
// a copy of the frequencies, and as the place where we put the result.
|
||||||
// This is fine because the output is always shorter than the input used
|
// This is fine because the output is always shorter than the input used
|
||||||
// so far.
|
// so far.
|
||||||
codegen := w.codegen // cache
|
codegen := w.codegen // cache
|
||||||
// Copy the concatenated code sizes to codegen. Put a marker at the end.
|
// Copy the concatenated code sizes to codegen. Put a marker at the end.
|
||||||
copyUint8s(codegen[0:numLiterals], w.literalEncoding.codeBits)
|
copy(codegen[0:numLiterals], w.literalEncoding.codeBits)
|
||||||
copyUint8s(codegen[numLiterals:numLiterals+numOffsets], w.offsetEncoding.codeBits)
|
copy(codegen[numLiterals:numLiterals+numOffsets], w.offsetEncoding.codeBits)
|
||||||
codegen[numLiterals+numOffsets] = badCode
|
codegen[numLiterals+numOffsets] = badCode
|
||||||
|
|
||||||
size := codegen[0]
|
size := codegen[0]
|
||||||
@ -222,7 +224,10 @@ func (w *huffmanBitWriter) generateCodegen(numLiterals int, numOffsets int) {
|
|||||||
w.codegenFreq[size]++
|
w.codegenFreq[size]++
|
||||||
count--
|
count--
|
||||||
for count >= 3 {
|
for count >= 3 {
|
||||||
n := min(count, 6)
|
n := 6
|
||||||
|
if n > count {
|
||||||
|
n = count
|
||||||
|
}
|
||||||
codegen[outIndex] = 16
|
codegen[outIndex] = 16
|
||||||
outIndex++
|
outIndex++
|
||||||
codegen[outIndex] = uint8(n - 3)
|
codegen[outIndex] = uint8(n - 3)
|
||||||
@ -232,7 +237,10 @@ func (w *huffmanBitWriter) generateCodegen(numLiterals int, numOffsets int) {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for count >= 11 {
|
for count >= 11 {
|
||||||
n := min(count, 138)
|
n := 138
|
||||||
|
if n > count {
|
||||||
|
n = count
|
||||||
|
}
|
||||||
codegen[outIndex] = 18
|
codegen[outIndex] = 18
|
||||||
outIndex++
|
outIndex++
|
||||||
codegen[outIndex] = uint8(n - 11)
|
codegen[outIndex] = uint8(n - 11)
|
||||||
@ -351,8 +359,12 @@ func (w *huffmanBitWriter) writeBlock(tokens []token, eof bool, input []byte) {
|
|||||||
if w.err != nil {
|
if w.err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
fillInt32s(w.literalFreq, 0)
|
for i := range w.literalFreq {
|
||||||
fillInt32s(w.offsetFreq, 0)
|
w.literalFreq[i] = 0
|
||||||
|
}
|
||||||
|
for i := range w.offsetFreq {
|
||||||
|
w.offsetFreq[i] = 0
|
||||||
|
}
|
||||||
|
|
||||||
n := len(tokens)
|
n := len(tokens)
|
||||||
tokens = tokens[0 : n+1]
|
tokens = tokens[0 : n+1]
|
||||||
|
@ -195,7 +195,9 @@ func (h *huffmanEncoder) bitCounts(list []literalNode, maxBits int32) []int32 {
|
|||||||
|
|
||||||
// The tree can't have greater depth than n - 1, no matter what. This
|
// The tree can't have greater depth than n - 1, no matter what. This
|
||||||
// saves a little bit of work in some small cases
|
// saves a little bit of work in some small cases
|
||||||
maxBits = minInt32(maxBits, n-1)
|
if maxBits > n-1 {
|
||||||
|
maxBits = n - 1
|
||||||
|
}
|
||||||
|
|
||||||
// Create information about each of the levels.
|
// Create information about each of the levels.
|
||||||
// A bogus "Level 0" whose sole purpose is so that
|
// A bogus "Level 0" whose sole purpose is so that
|
||||||
|
@ -1,72 +0,0 @@
|
|||||||
// Copyright 2009 The Go Authors. All rights reserved.
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
package flate
|
|
||||||
|
|
||||||
func min(left int, right int) int {
|
|
||||||
if left < right {
|
|
||||||
return left
|
|
||||||
}
|
|
||||||
return right
|
|
||||||
}
|
|
||||||
|
|
||||||
func minInt32(left int32, right int32) int32 {
|
|
||||||
if left < right {
|
|
||||||
return left
|
|
||||||
}
|
|
||||||
return right
|
|
||||||
}
|
|
||||||
|
|
||||||
func max(left int, right int) int {
|
|
||||||
if left > right {
|
|
||||||
return left
|
|
||||||
}
|
|
||||||
return right
|
|
||||||
}
|
|
||||||
|
|
||||||
func fillInts(a []int, value int) {
|
|
||||||
for i := range a {
|
|
||||||
a[i] = value
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func fillInt32s(a []int32, value int32) {
|
|
||||||
for i := range a {
|
|
||||||
a[i] = value
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func fillBytes(a []byte, value byte) {
|
|
||||||
for i := range a {
|
|
||||||
a[i] = value
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func fillInt8s(a []int8, value int8) {
|
|
||||||
for i := range a {
|
|
||||||
a[i] = value
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func fillUint8s(a []uint8, value uint8) {
|
|
||||||
for i := range a {
|
|
||||||
a[i] = value
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func copyInt8s(dst []int8, src []int8) int {
|
|
||||||
cnt := min(len(dst), len(src))
|
|
||||||
for i := 0; i < cnt; i++ {
|
|
||||||
dst[i] = src[i]
|
|
||||||
}
|
|
||||||
return cnt
|
|
||||||
}
|
|
||||||
|
|
||||||
func copyUint8s(dst []uint8, src []uint8) int {
|
|
||||||
cnt := min(len(dst), len(src))
|
|
||||||
for i := 0; i < cnt; i++ {
|
|
||||||
dst[i] = src[i]
|
|
||||||
}
|
|
||||||
return cnt
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user