Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-dms3-chunker
Commits
6a392e12
Unverified
Commit
6a392e12
authored
Sep 25, 2018
by
Steven Allen
Committed by
GitHub
Sep 25, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #8 from ipfs/feat/switch-to-buffer-pool
switch to go-buffer-pool
parents
b161c870
c10b0781
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
10 deletions
+10
-10
package.json
package.json
+6
-6
splitting.go
splitting.go
+4
-4
No files found.
package.json
View file @
6a392e12
...
...
@@ -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"
,
...
...
splitting.go
View file @
6a392e12
...
...
@@ -8,7 +8,7 @@ import (
"io"
logging
"github.com/ipfs/go-log"
m
pool
"github.com/libp2p/go-
msgio/m
pool"
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
:=
m
pool
.
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
)
m
pool
.
ByteSlicePool
.
Put
(
ss
.
size
,
full
)
pool
.
Put
(
full
)
return
small
,
nil
case
nil
:
return
full
,
nil
default
:
m
pool
.
ByteSlicePool
.
Put
(
ss
.
size
,
full
)
pool
.
Put
(
full
)
return
nil
,
err
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment