1
0
mirror of https://github.com/golang/go synced 2024-11-25 04:37:56 -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 {
case ch < 144:
// size 8, 000110000 .. 10111111
bits = ch + 48; size = 8; break;
bits = ch+48;
size = 8;
break;
case ch < 256:
// size 9, 110010000 .. 111111111
bits = ch + 400 - 144; size = 9; break;
bits = ch+400-144;
size = 9;
break;
case ch < 280:
// size 7, 0000000 .. 0010111
bits = ch - 256; size = 7; break;
bits = ch-256;
size = 7;
break;
default:
// size 8, 11000000 .. 11000111
bits = ch + 192 - 280; size = 8;
bits = ch+192-280;
size = 8;
}
codeBits[ch] = size;
code[ch] = reverseBits(bits, size);
@ -103,8 +110,8 @@ func generateFixedOffsetEncoding() *huffmanEncoder {
return h;
}
var fixedLiteralEncoding *huffmanEncoder = generateFixedLiteralEncoding();
var fixedOffsetEncoding *huffmanEncoder = generateFixedOffsetEncoding();
var fixedLiteralEncoding *huffmanEncoder = generateFixedLiteralEncoding()
var fixedOffsetEncoding *huffmanEncoder = generateFixedOffsetEncoding()
func (h *huffmanEncoder) bitLength(freq []int32) int64 {
var total int64;
@ -363,11 +370,11 @@ func (s literalNodeSorter) Swap(i,j int) {
}
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);
}
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);
}

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 {
var f inflater;
pr, pw := io.Pipe();
go func() {
pw.CloseWithError(f.inflater(r, pw));
}();
go func() { pw.CloseWithError(f.inflater(r, pw)) }();
return pr;
}