NewBytePool 创建新对象
(length int)
| 21 | |
| 22 | // NewBytePool 创建新对象 |
| 23 | func NewBytePool(length int) *BytePool { |
| 24 | if length < 0 { |
| 25 | length = 1024 |
| 26 | } |
| 27 | return &BytePool{ |
| 28 | length: length, |
| 29 | rawPool: &sync.Pool{ |
| 30 | New: func() any { |
| 31 | return &BytesBuf{ |
| 32 | Bytes: make([]byte, length), |
| 33 | } |
| 34 | }, |
| 35 | }, |
| 36 | } |
| 37 | } |
| 38 | |
| 39 | // Get 获取一个新的byte slice |
| 40 | func (this *BytePool) Get() *BytesBuf { |
no outgoing calls