1
0
mirror of https://github.com/imgproxy/imgproxy.git synced 2025-02-02 11:34:20 +02:00

Pregrow buffers on Get

This commit is contained in:
DarthSim 2019-01-30 17:45:31 +06:00
parent 250ee7914e
commit d63f0d5cbe
2 changed files with 4 additions and 4 deletions

View File

@ -118,6 +118,10 @@ func (p *bufPool) Get(size int) *bytes.Buffer {
buf.Reset() buf.Reset()
if size > 0 && size > buf.Cap() {
buf.Grow(size)
}
return buf return buf
} }

View File

@ -136,10 +136,6 @@ func readAndCheckImage(ctx context.Context, res *http.Response) (context.Context
downloadBufPool.Put(buf) downloadBufPool.Put(buf)
} }
if contentLength > buf.Cap() {
buf.Grow(contentLength - buf.Len())
}
body := res.Body body := res.Body
if conf.MaxSrcFileSize > 0 { if conf.MaxSrcFileSize > 0 {