Correct size of unmarshalling destination buffer.

The format header size is not deducted from the size of the byte
stream when calculating the output buffer size for samples.  I have
yet to notice problems directly as a result of this, but it is good
to fix.

Change-Id: Icb07a0718366c04ddac975d738a6305687773af0
This commit is contained in:
Matt T. Proud 2014-04-15 11:51:31 +02:00
parent 1d01435d4d
commit 6ec72393c4

View File

@ -171,7 +171,7 @@ func (v Values) marshal() []byte {
// unmarshalValues decodes marshalled samples and returns them as Values.
func unmarshalValues(buf []byte) Values {
n := len(buf) / sampleSize
n := (len(buf) - formatVersionSize) / sampleSize
// Setting the value of a given slice index is around 15% faster than doing
// an append, even if the slice already has the required capacity. For this
// reason, we already set the full target length here.