(size int)
| 61 | } |
| 62 | |
| 63 | func putPoolIdx(size int) int { |
| 64 | // Only exact power-of-2 sizes match pool buckets |
| 65 | if size&(size-1) != 0 { |
| 66 | return -1 |
| 67 | } |
| 68 | |
| 69 | // Calculate log2(size) using trailing zeros count |
| 70 | exp := bits.TrailingZeros(uint(size)) |
| 71 | idx := exp - minPoolExpOf2 |
| 72 | |
| 73 | if idx < 0 || idx >= len(pools) { |
| 74 | return -1 |
| 75 | } |
| 76 | |
| 77 | return idx |
| 78 | } |