Index: src/0dev.org/commands/pdc/main.go ================================================================== --- src/0dev.org/commands/pdc/main.go +++ src/0dev.org/commands/pdc/main.go @@ -1,12 +1,10 @@ package main import ( - pprof "0dev.org/debug/pprof" iou "0dev.org/ioutil" predictor "0dev.org/predictor" - // "bufio" "fmt" "io" "os" ) @@ -18,13 +16,10 @@ case len(os.Args) == 2 && os.Args[1] == "-d": code = decompress(os.Stdout, os.Stdin) default: fmt.Fprintln(os.Stdout, "Usage: pdc [-d]") } - - pprof.Stop() - os.Exit(code) } // Compress the data from the given io.Reader and write it to the given io.Writer // I/O is buffered for better performance @@ -63,11 +58,10 @@ func decompress(output io.Writer, input io.Reader) int { var ( err error buffer io.Writer = iou.SizedWriter(output, 4096) decompressor io.Reader = predictor.Decompressor(iou.SizedReader(input, 4096)) - //decompressor io.Reader = predictor.Decompressor(bufio.NewReader(input)) ) _, err = io.Copy(buffer, decompressor) if err != nil { fmt.Fprintln(os.Stderr, "Error while decompressing.\n", err) Index: src/0dev.org/ioutil/ioutil.go ================================================================== --- src/0dev.org/ioutil/ioutil.go +++ src/0dev.org/ioutil/ioutil.go @@ -105,18 +105,18 @@ err error ) start: // Reply with the buffered data if there is any - if sr.to-sr.from > 0 { + if sr.to > 0 { count = copy(output, sr.buffer[sr.from:sr.to]) // Advance the data in the buffer sr.from += count // Check whether we have reached the end of the buffer - if sr.to-sr.from == 0 { + if sr.from == sr.to { // Reset the buffer sr.from, sr.to = 0, 0 return count, err } @@ -134,12 +134,12 @@ count, err = sr.reader.Read(sr.buffer) // Size the buffer down to the read data size // and restart if we have successfully read some bytes sr.from, sr.to = 0, count - if sr.to-sr.from > 0 { + if sr.to > 0 { goto start } // Returning on err/misbehaving noop reader return 0, err }