(pools int)
| 20 | } |
| 21 | |
| 22 | func (sp *byteSlicePools) init(pools int) { |
| 23 | sp.pools = make([]sync.Pool, pools) |
| 24 | for i := range pools { |
| 25 | size := int(math.Pow(2, float64(i+minPoolSizePower))) |
| 26 | sp.pools[i] = sync.Pool{ |
| 27 | New: func() any { |
| 28 | buf := make([]byte, 0, size) |
| 29 | return &buf |
| 30 | }, |
| 31 | } |
| 32 | } |
| 33 | } |
| 34 | |
| 35 | func (sp *byteSlicePools) getSlice(size int) *[]byte { |
| 36 | index := int(math.Ceil(math.Log2(float64(size)))) - minPoolSizePower |