Reuse buffers on socket pumping

This commit is contained in:
9seconds
2018-06-20 09:33:57 +03:00
parent c76d8307c2
commit 2c938d2848
2 changed files with 29 additions and 8 deletions
+16
View File
@@ -0,0 +1,16 @@
package proxy
import "sync"
const copyBufferSize = 30 * 1024
var copyPool sync.Pool
func init() {
copyPool = sync.Pool{
New: func() interface{} {
data := make([]byte, copyBufferSize)
return &data
},
}
}