mirror of
https://github.com/vbatts/tar-split.git
synced 2024-12-18 11:36:30 +00:00
Merge pull request #54 from mtrmac/allocations
Avoid a 32 kB file allocation on every bitBucketFilePutter.Put
This commit is contained in:
commit
80a436fd61
1 changed files with 2 additions and 1 deletions
|
@ -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
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue