diff options
author | Ian Lance Taylor <ian@gcc.gnu.org> | 2012-02-09 08:19:58 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2012-02-09 08:19:58 +0000 |
commit | 94252f4bcc0a3f487b804ce535cb77b8bef4db83 (patch) | |
tree | 7ca86535c5a6b99d4cc432ba5cfddabc5ee4ea16 /libgo/go/compress | |
parent | cd6368115dbd75d9187877097c48a0d8d4c04fd4 (diff) | |
download | gcc-94252f4bcc0a3f487b804ce535cb77b8bef4db83.zip gcc-94252f4bcc0a3f487b804ce535cb77b8bef4db83.tar.gz gcc-94252f4bcc0a3f487b804ce535cb77b8bef4db83.tar.bz2 |
libgo: Update to weekly.2012-02-07.
From-SVN: r184034
Diffstat (limited to 'libgo/go/compress')
-rw-r--r-- | libgo/go/compress/flate/deflate.go | 2 | ||||
-rw-r--r-- | libgo/go/compress/flate/deflate_test.go | 6 | ||||
-rw-r--r-- | libgo/go/compress/flate/huffman_code.go | 55 | ||||
-rw-r--r-- | libgo/go/compress/lzw/reader_test.go | 6 | ||||
-rw-r--r-- | libgo/go/compress/zlib/writer_test.go | 4 |
5 files changed, 9 insertions, 64 deletions
diff --git a/libgo/go/compress/flate/deflate.go b/libgo/go/compress/flate/deflate.go index 1e72589..8505da7 100644 --- a/libgo/go/compress/flate/deflate.go +++ b/libgo/go/compress/flate/deflate.go @@ -102,7 +102,7 @@ func (d *compressor) fillDeflate(b []byte) int { if d.blockStart >= windowSize { d.blockStart -= windowSize } else { - d.blockStart = skipNever + d.blockStart = math.MaxInt32 } d.hashOffset += windowSize } diff --git a/libgo/go/compress/flate/deflate_test.go b/libgo/go/compress/flate/deflate_test.go index 24881d3..75d801d 100644 --- a/libgo/go/compress/flate/deflate_test.go +++ b/libgo/go/compress/flate/deflate_test.go @@ -229,14 +229,14 @@ func testToFromWithLevel(t *testing.T, level int, input []byte, name string) err } func testToFromWithLevelAndLimit(t *testing.T, level int, input []byte, name string, limit int) error { - buffer := bytes.NewBuffer(nil) - w := NewWriter(buffer, level) + var buffer bytes.Buffer + w := NewWriter(&buffer, level) w.Write(input) w.Close() if limit > 0 && buffer.Len() > limit { t.Errorf("level: %d, len(compress(data)) = %d > limit = %d", level, buffer.Len(), limit) } - r := NewReader(buffer) + r := NewReader(&buffer) out, err := ioutil.ReadAll(r) if err != nil { t.Errorf("read: %s", err) diff --git a/libgo/go/compress/flate/huffman_code.go b/libgo/go/compress/flate/huffman_code.go index 4873b0f..009cce6 100644 --- a/libgo/go/compress/flate/huffman_code.go +++ b/libgo/go/compress/flate/huffman_code.go @@ -121,61 +121,6 @@ func (h *huffmanEncoder) bitLength(freq []int32) int64 { return total } -// Generate elements in the chain using an iterative algorithm. -func (h *huffmanEncoder) generateChains(top *levelInfo, list []literalNode) { - n := len(list) - list = list[0 : n+1] - list[n] = maxNode() - - l := top - for { - if l.nextPairFreq == math.MaxInt32 && l.nextCharFreq == math.MaxInt32 { - // We've run out of both leafs and pairs. - // End all calculations for this level. - // To m sure we never come back to this level or any lower level, - // set nextPairFreq impossibly large. - l.lastChain = nil - l.needed = 0 - l = l.up - l.nextPairFreq = math.MaxInt32 - continue - } - - prevFreq := l.lastChain.freq - if l.nextCharFreq < l.nextPairFreq { - // The next item on this row is a leaf node. - n := l.lastChain.leafCount + 1 - l.lastChain = &chain{l.nextCharFreq, n, l.lastChain.up} - l.nextCharFreq = list[n].freq - } else { - // The next item on this row is a pair from the previous row. - // nextPairFreq isn't valid until we generate two - // more values in the level below - l.lastChain = &chain{l.nextPairFreq, l.lastChain.leafCount, l.down.lastChain} - l.down.needed = 2 - } - - if l.needed--; l.needed == 0 { - // We've done everything we need to do for this level. - // Continue calculating one level up. Fill in nextPairFreq - // of that level with the sum of the two nodes we've just calculated on - // this level. - up := l.up - if up == nil { - // All done! - return - } - up.nextPairFreq = prevFreq + l.lastChain.freq - l = up - } else { - // If we stole from below, move down temporarily to replenish it. - for l.down.needed > 0 { - l = l.down - } - } - } -} - // Return the number of literals assigned to each bit size in the Huffman encoding // // This method is only called when list.length >= 3 diff --git a/libgo/go/compress/lzw/reader_test.go b/libgo/go/compress/lzw/reader_test.go index 0982157..e5be12f 100644 --- a/libgo/go/compress/lzw/reader_test.go +++ b/libgo/go/compress/lzw/reader_test.go @@ -81,7 +81,7 @@ var lzwTests = []lzwTest{ } func TestReader(t *testing.T) { - b := bytes.NewBuffer(nil) + var b bytes.Buffer for _, tt := range lzwTests { d := strings.Split(tt.desc, ";") var order Order @@ -97,7 +97,7 @@ func TestReader(t *testing.T) { rc := NewReader(strings.NewReader(tt.compressed), order, litWidth) defer rc.Close() b.Reset() - n, err := io.Copy(b, rc) + n, err := io.Copy(&b, rc) if err != nil { if err != tt.err { t.Errorf("%s: io.Copy: %v want %v", tt.desc, err, tt.err) @@ -116,7 +116,7 @@ func benchmarkDecoder(b *testing.B, n int) { b.SetBytes(int64(n)) buf0, _ := ioutil.ReadFile("../testdata/e.txt") buf0 = buf0[:10000] - compressed := bytes.NewBuffer(nil) + compressed := new(bytes.Buffer) w := NewWriter(compressed, LSB, 8) for i := 0; i < n; i += len(buf0) { io.Copy(w, bytes.NewBuffer(buf0)) diff --git a/libgo/go/compress/zlib/writer_test.go b/libgo/go/compress/zlib/writer_test.go index a71894d..1c75d08 100644 --- a/libgo/go/compress/zlib/writer_test.go +++ b/libgo/go/compress/zlib/writer_test.go @@ -124,8 +124,8 @@ func TestWriterDict(t *testing.T) { func TestWriterDictIsUsed(t *testing.T) { var input = []byte("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.") - buf := bytes.NewBuffer(nil) - compressor, err := NewWriterDict(buf, BestCompression, input) + var buf bytes.Buffer + compressor, err := NewWriterDict(&buf, BestCompression, input) if err != nil { t.Errorf("error in NewWriterDict: %s", err) return |