mirror of
https://github.com/ehang-io/nps.git
synced 2026-11-01 09:12:12 +08:00
fix buffer size bug
This commit is contained in:
1 parent
53c2e472ae
commit
41c282b38b
4 files changed
+35
-20
No files matched your search
+3
-2
@@ -66,13 +66,14 @@ type CopyBufferPool struct {
|
||||
func (Self *CopyBufferPool) New() {
|
||||
Self.pool = sync.Pool{
|
||||
New: func() interface{} {
|
||||
return make([]byte, PoolSizeCopy)
|
||||
return make([]byte, PoolSizeCopy, PoolSizeCopy)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (Self *CopyBufferPool) Get() []byte {
|
||||
return Self.pool.Get().([]byte)
|
||||
buf := Self.pool.Get().([]byte)
|
||||
return buf[:cap(buf)] // grow to capacity
|
||||
}
|
||||
|
||||
func (Self *CopyBufferPool) Put(x []byte) {
|
||||
|
||||
Reference in new issue
Block a user