summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWill Hawkins <[email protected]>2021-12-18 01:15:50 -0500
committerWill Hawkins <[email protected]>2021-12-18 01:15:50 -0500
commitc6574f4232efe259f225d443df5db442fa240052 (patch)
tree0c7c30e7d78199c4658c4b9488ab4d3044b07dc9
parent1ee83b005be490ff693be99b4e6359efec642fcd (diff)
Performance (Try 3): Experiment with preallocating buffers.
-rw-r--r--lbc/lbc.go4
1 files changed, 3 insertions, 1 deletions
diff --git a/lbc/lbc.go b/lbc/lbc.go
index d0014dd..5cfcf9f 100644
--- a/lbc/lbc.go
+++ b/lbc/lbc.go
@@ -4,6 +4,7 @@ import (
"context"
"fmt"
"io"
+ "io/ioutil"
"net/http"
"sync/atomic"
)
@@ -90,8 +91,9 @@ func (lbd *LoadBearingConnectionDownload) doDownload(ctx context.Context) {
lbd.valid = false
return
}
+ buff := make([]byte, 500*1024*1024)
cr := &countingReader{n: &lbd.downloaded, ctx: ctx, readable: get.Body}
- _, _ = io.ReadAll(cr)
+ _, _ = io.CopyBuffer(ioutil.Discard, cr, buff)
lbd.valid = false
get.Body.Close()
if lbd.debug {