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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
}

// Decompress the data from the given io.Reader and write it to the given io.Writer
// I/O is buffered for better performance
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))
	)

	_, err = io.Copy(buffer, decompressor)
	if err != nil {
		fmt.Fprintln(os.Stderr, "Error while decompressing.\n", err)
		return 1
	}

	// Flush the buffer
	_, err = buffer.Write(nil)
	if err != nil {
		fmt.Fprintln(os.Stderr, "Error while flushing output buffer.\n", err)
		return 1
	}

	return 0
}







<



|





<
<
<
<
<
<
<


54
55
56
57
58
59
60

61
62
63
64
65
66
67
68
69







70
71
}

// Decompress the data from the given io.Reader and write it to the given io.Writer
// I/O is buffered for better performance
func decompress(output io.Writer, input io.Reader) int {
	var (
		err          error

		decompressor io.Reader = predictor.Decompressor(iou.SizedReader(input, 4096))
	)

	_, err = io.Copy(output, decompressor)
	if err != nil {
		fmt.Fprintln(os.Stderr, "Error while decompressing.\n", err)
		return 1
	}








	return 0
}