diff --git a/pool.go b/pool.go index 2c8681e4d792c2d5005fdf7094838836d3eb55b8..b913431d1dfe5ec72ee3f7b997c2cf7dc1738fc9 100644 --- a/pool.go +++ b/pool.go @@ -26,12 +26,10 @@ import ( ) // ByteSlicePool is a static Pool for reusing byteslices of various sizes. -var ByteSlicePool Pool - -func init() { - ByteSlicePool.New = func(length int) interface{} { +var ByteSlicePool = &Pool{ + New: func(length int) interface{} { return make([]byte, length) - } + }, } // MaxLength is the maximum length of an element that can be added to the Pool. diff --git a/pool_test.go b/pool_test.go index 9aaf32f6393391ac7c1664cd9fdf6c5366e4db3c..cf019c6fc62cd35a8db20e540ead4ba283eedc3c 100644 --- a/pool_test.go +++ b/pool_test.go @@ -162,7 +162,7 @@ func TestPoolStressByteSlicePool(t *testing.T) { if testing.Short() { N /= 100 } - p := &ByteSlicePool + p := ByteSlicePool done := make(chan bool) errs := make(chan error) for i := 0; i < P; i++ {