Overview
Comment: | Removed pdc's output buffer when decompressing as io.Copy uses a sufficiently-large buffer internally. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
2b1ed8e45e9dcc2474d875144b95085f |
User & Date: | spaskalev on 2014-12-25 01:25:56 |
Other Links: | manifest | tags |
Context
2014-12-25
| ||
08:48 | Allocate the predictor's decompression buffer per Read call. check-in: f06f8cd058 user: spaskalev tags: trunk | |
01:25 | Removed pdc's output buffer when decompressing as io.Copy uses a sufficiently-large buffer internally. check-in: 2b1ed8e45e user: spaskalev tags: trunk | |
00:55 | Predictor's compressor and decompressor structures now implement io.Writer/io.Reader in order to deal away with function indirection but they do not follow the required semantics. Those are provided by the SizedWriter/SizedReader wrappers returned by the constructor functions. check-in: 4dfcff962c user: spaskalev tags: trunk | |
Changes
Modified src/0dev.org/commands/pdc/main.go from [dfe0b7b6cf] to [9aabc03cac].
54 54 } 55 55 56 56 // Decompress the data from the given io.Reader and write it to the given io.Writer 57 57 // I/O is buffered for better performance 58 58 func decompress(output io.Writer, input io.Reader) int { 59 59 var ( 60 60 err error 61 - buffer io.Writer = iou.SizedWriter(output, 4096) 62 61 decompressor io.Reader = predictor.Decompressor(iou.SizedReader(input, 4096)) 63 62 ) 64 63 65 - _, err = io.Copy(buffer, decompressor) 64 + _, err = io.Copy(output, decompressor) 66 65 if err != nil { 67 66 fmt.Fprintln(os.Stderr, "Error while decompressing.\n", err) 68 67 return 1 69 68 } 70 69 71 - // Flush the buffer 72 - _, err = buffer.Write(nil) 73 - if err != nil { 74 - fmt.Fprintln(os.Stderr, "Error while flushing output buffer.\n", err) 75 - return 1 76 - } 77 - 78 70 return 0 79 71 }