mirror of
https://github.com/octoleo/syncthing.git
synced 2025-01-31 02:48:27 +00:00
lib/scanner: Avoid per iteration allocations in Blocks()
Resetting the io.LimitReader is better than creating a new one on every iteration.
This commit is contained in:
parent
4c8aa14e07
commit
68f1c6ccab
@ -45,8 +45,9 @@ func Blocks(r io.Reader, blocksize int, sizehint int64, counter Counter) ([]prot
|
||||
buf := make([]byte, 32<<10)
|
||||
|
||||
var offset int64
|
||||
lr := io.LimitReader(r, int64(blocksize)).(*io.LimitedReader)
|
||||
for {
|
||||
lr := io.LimitReader(r, int64(blocksize))
|
||||
lr.N = int64(blocksize)
|
||||
n, err := io.CopyBuffer(mhf, lr, buf)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
Loading…
x
Reference in New Issue
Block a user