Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(673)

Side by Side Diff: src/compress/bzip2/bzip2.go

Issue 147380043: code review 147380043: compress/*: note that NewReader may introduce buffering (Closed)
Patch Set: diff -r d539076652f878dd581537c4d30edd2b811877dc https://code.google.com/p/go/ Created 10 years, 5 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/compress/flate/inflate.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 The Go Authors. All rights reserved. 1 // Copyright 2011 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 // Package bzip2 implements bzip2 decompression. 5 // Package bzip2 implements bzip2 decompression.
6 package bzip2 6 package bzip2
7 7
8 import "io" 8 import "io"
9 9
10 // There's no RFC for bzip2. I used the Wikipedia page for reference and a lot 10 // There's no RFC for bzip2. I used the Wikipedia page for reference and a lot
(...skipping 24 matching lines...) Expand all
35 tPos uint32 // Index of the next output byte in tt. 35 tPos uint32 // Index of the next output byte in tt.
36 36
37 preRLE []uint32 // contains the RLE data still to be processed. 37 preRLE []uint32 // contains the RLE data still to be processed.
38 preRLEUsed int // number of entries of preRLE used. 38 preRLEUsed int // number of entries of preRLE used.
39 lastByte int // the last byte value seen. 39 lastByte int // the last byte value seen.
40 byteRepeats uint // the number of repeats of lastByte seen. 40 byteRepeats uint // the number of repeats of lastByte seen.
41 repeats uint // the number of copies of lastByte to output. 41 repeats uint // the number of copies of lastByte to output.
42 } 42 }
43 43
44 // NewReader returns an io.Reader which decompresses bzip2 data from r. 44 // NewReader returns an io.Reader which decompresses bzip2 data from r.
45 // If r does not also implement io.ByteReader,
46 // the decompressor may read more data than necessary from r.
45 func NewReader(r io.Reader) io.Reader { 47 func NewReader(r io.Reader) io.Reader {
46 bz2 := new(reader) 48 bz2 := new(reader)
47 bz2.br = newBitReader(r) 49 bz2.br = newBitReader(r)
48 return bz2 50 return bz2
49 } 51 }
50 52
51 const bzip2FileMagic = 0x425a // "BZ" 53 const bzip2FileMagic = 0x425a // "BZ"
52 const bzip2BlockMagic = 0x314159265359 54 const bzip2BlockMagic = 0x314159265359
53 const bzip2FinalMagic = 0x177245385090 55 const bzip2FinalMagic = 0x177245385090
54 56
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after
492 494
493 // updateCRC updates the crc value to incorporate the data in b. 495 // updateCRC updates the crc value to incorporate the data in b.
494 // The initial value is 0. 496 // The initial value is 0.
495 func updateCRC(val uint32, b []byte) uint32 { 497 func updateCRC(val uint32, b []byte) uint32 {
496 crc := ^val 498 crc := ^val
497 for _, v := range b { 499 for _, v := range b {
498 crc = crctab[byte(crc>>24)^v] ^ (crc << 8) 500 crc = crctab[byte(crc>>24)^v] ^ (crc << 8)
499 } 501 }
500 return ^crc 502 return ^crc
501 } 503 }
OLDNEW
« no previous file with comments | « no previous file | src/compress/flate/inflate.go » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b