@@ -43,7 +43,7 @@ type BufferPool interface {
4343const goPageSizeExponent = 12
4444const goPageSize = 1 << goPageSizeExponent // 4KiB. N.B. this must be a power of 2.
4545
46- var defaultBufferPoolSizeExponents = []int {
46+ var defaultBufferPoolSizeExponents = []uint {
4747 8 ,
4848 goPageSizeExponent ,
4949 14 , // 16KB (max HTTP/2 frame size used by gRPC)
@@ -135,8 +135,8 @@ type binaryTieredBufferPool struct {
135135// capacity of the buffers in the pool, not the capacities of the buffers
136136// themselves. For example, if you wanted a pool that had buffers with a capacity
137137// of 16kb, you would pass 14 as the argument to this function.
138- func NewBinaryTieredBufferPool (powerOfTwoExponents ... int ) BufferPool {
139- sort . Ints (powerOfTwoExponents )
138+ func NewBinaryTieredBufferPool (powerOfTwoExponents ... uint ) BufferPool {
139+ slices . Sort (powerOfTwoExponents )
140140
141141 // Determine the maximum exponent we need to support.
142142 // bits.Len64(math.MaxUint64) is 63.
@@ -150,11 +150,7 @@ func NewBinaryTieredBufferPool(powerOfTwoExponents ...int) BufferPool {
150150 for i , exp := range powerOfTwoExponents {
151151 // Allocating slices of size > 2^maxExponent isn't possible on 64-bit
152152 // machines.
153- //
154- // Negative exponents would result in values in the range (0, 1). Since
155- // buffer sizes are integers, such values don't make sense (and would
156- // panic on bit shift). We ignore such values.
157- if exp > maxExponent || exp < 0 {
153+ if exp > maxExponent {
158154 continue
159155 }
160156 capSize := 1 << exp
0 commit comments