diff --git a/package.json b/package.json index 4219981..1783022 100644 --- a/package.json +++ b/package.json @@ -12,12 +12,6 @@ "name": "go-log", "version": "1.5.7" }, - { - "author": "jbenet", - "hash": "QmWBug6eBS7AxRdCDVuSY5CnSit7cS2XnPFYJWqWDumhCG", - "name": "go-msgio", - "version": "0.0.3" - }, { "author": "whyrusleeping", "hash": "QmZooytqEoUwQjv7KzH4d3xyJnyvD3AWJaCDMYt5pbCtua", @@ -35,6 +29,12 @@ "hash": "QmRcHuYzAyswytBuMF78rj3LTChYszomRFXNg4685ZN1WM", "name": "go-block-format", "version": "0.2.0" + }, + { + "author": "Stebalien", + "hash": "QmUQy76yspPa3fRyY3GzXFTg9n8JVwFru6ue3KFRt4MeTw", + "name": "go-buffer-pool", + "version": "0.1.1" } ], "gxVersion": "0.12.1", diff --git a/splitting.go b/splitting.go index 6a10de0..2b23739 100644 --- a/splitting.go +++ b/splitting.go @@ -8,7 +8,7 @@ import ( "io" logging "github.com/ipfs/go-log" - mpool "github.com/libp2p/go-msgio/mpool" + pool "github.com/libp2p/go-buffer-pool" ) var log = logging.Logger("chunk") @@ -82,19 +82,19 @@ func (ss *sizeSplitterv2) NextBytes() ([]byte, error) { return nil, ss.err } - full := mpool.ByteSlicePool.Get(ss.size).([]byte)[:ss.size] + full := pool.Get(int(ss.size)) n, err := io.ReadFull(ss.r, full) switch err { case io.ErrUnexpectedEOF: ss.err = io.EOF small := make([]byte, n) copy(small, full) - mpool.ByteSlicePool.Put(ss.size, full) + pool.Put(full) return small, nil case nil: return full, nil default: - mpool.ByteSlicePool.Put(ss.size, full) + pool.Put(full) return nil, err } }