Commit 5ef65a03 authored by Steven Allen's avatar Steven Allen

make ByteSlicePool a *Pool, not a Pool.

This way, copying it won't copy the underlying pool.

Also, initialize it immediately instead of in an `init` function to ensure that
it's fully initialized immediately.
parent 4120bea2
......@@ -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.
......
......@@ -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++ {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment