1
0
mirror of https://github.com/golang/go synced 2024-11-25 06:07:58 -07:00

gofmt-ify compress

R=rsc
http://go/go-review/1016045
This commit is contained in:
Robert Griesemer 2009-11-04 17:10:18 -08:00
parent b6d0a22dc5
commit 5fca0bca61
3 changed files with 61 additions and 56 deletions

View File

@ -75,16 +75,23 @@ func generateFixedLiteralEncoding() *huffmanEncoder {
switch { switch {
case ch < 144: case ch < 144:
// size 8, 000110000 .. 10111111 // size 8, 000110000 .. 10111111
bits = ch + 48; size = 8; break; bits = ch+48;
size = 8;
break;
case ch < 256: case ch < 256:
// size 9, 110010000 .. 111111111 // size 9, 110010000 .. 111111111
bits = ch + 400 - 144; size = 9; break; bits = ch+400-144;
size = 9;
break;
case ch < 280: case ch < 280:
// size 7, 0000000 .. 0010111 // size 7, 0000000 .. 0010111
bits = ch - 256; size = 7; break; bits = ch-256;
size = 7;
break;
default: default:
// size 8, 11000000 .. 11000111 // size 8, 11000000 .. 11000111
bits = ch + 192 - 280; size = 8; bits = ch+192-280;
size = 8;
} }
codeBits[ch] = size; codeBits[ch] = size;
code[ch] = reverseBits(bits, size); code[ch] = reverseBits(bits, size);
@ -103,8 +110,8 @@ func generateFixedOffsetEncoding() *huffmanEncoder {
return h; return h;
} }
var fixedLiteralEncoding *huffmanEncoder = generateFixedLiteralEncoding(); var fixedLiteralEncoding *huffmanEncoder = generateFixedLiteralEncoding()
var fixedOffsetEncoding *huffmanEncoder = generateFixedOffsetEncoding(); var fixedOffsetEncoding *huffmanEncoder = generateFixedOffsetEncoding()
func (h *huffmanEncoder) bitLength(freq []int32) int64 { func (h *huffmanEncoder) bitLength(freq []int32) int64 {
var total int64; var total int64;
@ -363,11 +370,11 @@ func (s literalNodeSorter) Swap(i,j int) {
} }
func sortByFreq(a []literalNode) { func sortByFreq(a []literalNode) {
s := &literalNodeSorter { a, func(i, j int) bool { return a[i].freq < a[j].freq; }}; s := &literalNodeSorter{a, func(i, j int) bool { return a[i].freq < a[j].freq }};
sort.Sort(s); sort.Sort(s);
} }
func sortByLiteral(a []literalNode) { func sortByLiteral(a []literalNode) {
s := &literalNodeSorter{ a, func(i, j int) bool { return a[i].literal < a[j].literal; }}; s := &literalNodeSorter{a, func(i, j int) bool { return a[i].literal < a[j].literal }};
sort.Sort(s); sort.Sort(s);
} }

View File

@ -609,8 +609,6 @@ func (f *inflater) inflater(r io.Reader, w io.Writer) os.Error {
func NewInflater(r io.Reader) io.ReadCloser { func NewInflater(r io.Reader) io.ReadCloser {
var f inflater; var f inflater;
pr, pw := io.Pipe(); pr, pw := io.Pipe();
go func() { go func() { pw.CloseWithError(f.inflater(r, pw)) }();
pw.CloseWithError(f.inflater(r, pw));
}();
return pr; return pr;
} }