getBucketForLen returns the bucket where we should get a slice of a certain length. Each bucket is guaranteed to hold slices that are precisely the block size for that bucket, so if the block size is larger than our size we are good.
(len int)
| 77 | // precisely the block size for that bucket, so if the block size is larger |
| 78 | // than our size we are good. |
| 79 | func getBucketForLen(len int) int { |
| 80 | for i, blockSize := range BlockSizes { |
| 81 | if len <= blockSize { |
| 82 | return i |
| 83 | } |
| 84 | } |
| 85 | |
| 86 | panic(fmt.Sprintf("bug: tried to get impossible block len %d", len)) |
| 87 | } |
| 88 | |
| 89 | // putBucketForCap returns the bucket where we should put a slice of a |
| 90 | // certain capacity. Each bucket is guaranteed to hold slices that are |
no outgoing calls