Skip to content

Commit

Permalink
Merge pull request #4 from libp2p/fix/pool-ref
Browse files Browse the repository at this point in the history
make ByteSlicePool a *Pool, not a Pool.
  • Loading branch information
Kubuxu authored Nov 21, 2017
2 parents fa984f5 + 4de8afb commit e1d4bc0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
8 changes: 3 additions & 5 deletions mpool/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion mpool/pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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++ {
Expand Down

0 comments on commit e1d4bc0

Please sign in to comment.