mirror of
https://github.com/nadoo/glider.git
synced 2026-11-23 23:49:41 +08:00
forwarder: avoid to disable direct forwarder
This commit is contained in:
1 parent
a9a1985a4b
commit
2fe9c3990b
4 files changed
+11
-6
No files matched your search
@@ -21,6 +21,7 @@ func initPools(sizes []int) []sync.Pool {
|
||||
return pools
|
||||
}
|
||||
|
||||
// GetBuffer returns a buffer from pool.
|
||||
func GetBuffer(size int) []byte {
|
||||
i := 0
|
||||
for ; i < len(bufSizes)-1; i++ {
|
||||
@@ -31,6 +32,7 @@ func GetBuffer(size int) []byte {
|
||||
return bufPools[i].Get().([]byte)[:size]
|
||||
}
|
||||
|
||||
// PutBuffer puts a buffer into pool.
|
||||
func PutBuffer(p []byte) {
|
||||
l := len(p)
|
||||
for i, n := range bufSizes {
|
||||
|
||||
@@ -9,10 +9,12 @@ var writeBufPool = sync.Pool{
|
||||
New: func() interface{} { return &bytes.Buffer{} },
|
||||
}
|
||||
|
||||
// GetWriteBuffer returns a bytes.buffer from pool.
|
||||
func GetWriteBuffer() *bytes.Buffer {
|
||||
return writeBufPool.Get().(*bytes.Buffer)
|
||||
}
|
||||
|
||||
// PutWriteBuffer puts a bytes.buffer into pool.
|
||||
func PutWriteBuffer(buf *bytes.Buffer) {
|
||||
if buf.Cap() > 64<<10 {
|
||||
return
|
||||
|
||||
Reference in new issue
Block a user