1
0
Fork 1
mirror of https://github.com/vbatts/tar-split.git synced 2024-11-15 04:58:36 +00:00

Merge pull request #54 from mtrmac/allocations

Avoid a 32 kB file allocation on every bitBucketFilePutter.Put
This commit is contained in:
Vincent Batts 2021-08-23 06:18:35 -04:00 committed by GitHub
commit 80a436fd61
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -92,11 +92,12 @@ func NewDiscardFilePutter() FilePutter {
}
type bitBucketFilePutter struct {
buffer [32 * 1024]byte // 32 kB is the buffer size currently used by io.Copy, as of August 2021.
}
func (bbfp *bitBucketFilePutter) Put(name string, r io.Reader) (int64, []byte, error) {
c := crc64.New(CRCTable)
i, err := io.Copy(c, r)
i, err := io.CopyBuffer(c, r, bbfp.buffer[:])
return i, c.Sum(nil), err
}