Check-in [2b1ed8e45e]
Overview
SHA1:2b1ed8e45e9dcc2474d875144b95085f7c711570
Date: 2014-12-25 01:25:56
User: spaskalev
Comment:Removed pdc's output buffer when decompressing as io.Copy uses a sufficiently-large buffer internally.
Timelines: family | ancestors | descendants | both | trunk
Downloads: Tarball | ZIP archive
Other Links: files | file ages | folders | manifest
Tags And Properties
Context
2014-12-25
08:48
[f06f8cd058] Allocate the predictor's decompression buffer per Read call. (user: spaskalev, tags: trunk)
01:25
[2b1ed8e45e] Removed pdc's output buffer when decompressing as io.Copy uses a sufficiently-large buffer internally. (user: spaskalev, tags: trunk)
00:55
[4dfcff962c] 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. (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   }