Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neo
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
Kirill Smelkov
neo
Commits
bf213313
Commit
bf213313
authored
Feb 21, 2018
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
X client: Cleanup a bit around decompressing
parent
57524491
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
8 additions
and
12 deletions
+8
-12
go/neo/client.go
go/neo/client.go
+2
-5
go/neo/internal/xzlib/xzlib.go
go/neo/internal/xzlib/xzlib.go
+2
-5
go/neo/internal/xzlib/xzlib_test.go
go/neo/internal/xzlib/xzlib_test.go
+1
-1
go/neo/storage.go
go/neo/storage.go
+2
-0
go/neo/t/tcpu.go
go/neo/t/tcpu.go
+1
-1
No files found.
go/neo/client.go
View file @
bf213313
...
@@ -464,13 +464,10 @@ func (c *Client) _Load(ctx context.Context, xid zodb.Xid) (*mem.Buf, zodb.Tid, e
...
@@ -464,13 +464,10 @@ func (c *Client) _Load(ctx context.Context, xid zodb.Xid) (*mem.Buf, zodb.Tid, e
}
}
if
resp
.
Compression
{
if
resp
.
Compression
{
// XXX cleanup mess vvv
buf2
:=
&
mem
.
Buf
{
Data
:
nil
}
buf2
:=
mem
.
BufAlloc
(
len
(
buf
.
Data
))
udata
,
err
:=
xzlib
.
Decompress
(
buf
.
Data
)
buf2
.
Data
=
buf2
.
Data
[
:
0
]
udata
,
err
:=
xzlib
.
Decompress
(
buf
.
Data
,
buf2
.
Data
)
buf
.
Release
()
buf
.
Release
()
if
err
!=
nil
{
if
err
!=
nil
{
buf2
.
Release
()
return
nil
,
0
,
fmt
.
Errorf
(
"data corrupt: %v"
,
err
)
return
nil
,
0
,
fmt
.
Errorf
(
"data corrupt: %v"
,
err
)
}
}
buf2
.
Data
=
udata
buf2
.
Data
=
udata
...
...
go/neo/internal/xzlib/xzlib.go
View file @
bf213313
...
@@ -65,12 +65,9 @@ func Compress(data []byte) (zdata []byte) {
...
@@ -65,12 +65,9 @@ func Compress(data []byte) (zdata []byte) {
// Decompress decompresses data according to zlib encoding.
// Decompress decompresses data according to zlib encoding.
//
//
// out buffer, if there is enough capacity, is used for decompression destination.
// if out has not enough capacity a new buffer is allocated and used.
//
// return: destination buffer with full decompressed data or error.
// return: destination buffer with full decompressed data or error.
func
Decompress
(
in
[]
byte
,
out
[]
byte
)
(
data
[]
byte
,
err
error
)
{
func
Decompress
(
zdata
[]
byte
)
(
data
[]
byte
,
err
error
)
{
return
czlib
.
Decompress
(
in
)
return
czlib
.
Decompress
(
zdata
)
}
}
/*
/*
...
...
go/neo/internal/xzlib/xzlib_test.go
View file @
bf213313
...
@@ -38,7 +38,7 @@ var ztestv = []struct{in, out string}{
...
@@ -38,7 +38,7 @@ var ztestv = []struct{in, out string}{
func
TestDecompress
(
t
*
testing
.
T
)
{
func
TestDecompress
(
t
*
testing
.
T
)
{
for
_
,
tt
:=
range
ztestv
{
for
_
,
tt
:=
range
ztestv
{
got
,
err
:=
Decompress
([]
byte
(
tt
.
in
)
,
nil
)
got
,
err
:=
Decompress
([]
byte
(
tt
.
in
))
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Errorf
(
"decompress err: %q"
,
tt
.
in
)
t
.
Errorf
(
"decompress err: %q"
,
tt
.
in
)
continue
continue
...
...
go/neo/storage.go
View file @
bf213313
...
@@ -471,6 +471,8 @@ func (stor *Storage) serveLink(ctx context.Context, req *neonet.Request, idReq *
...
@@ -471,6 +471,8 @@ func (stor *Storage) serveLink(ctx context.Context, req *neonet.Request, idReq *
return
err
return
err
}
}
// XXX this go + link.Recv1() in serveClient arrange for N(goroutine) ↑
// with O(1/nreq) rate (i.e. N(goroutine, nreq) ~ ln(nreq)).
wg
.
Add
(
1
)
wg
.
Add
(
1
)
go
func
()
{
go
func
()
{
defer
wg
.
Done
()
defer
wg
.
Done
()
...
...
go/neo/t/tcpu.go
View file @
bf213313
...
@@ -109,7 +109,7 @@ func BenchmarkUnzlib(b *testing.B, zfile string) {
...
@@ -109,7 +109,7 @@ func BenchmarkUnzlib(b *testing.B, zfile string) {
b
.
ResetTimer
()
b
.
ResetTimer
()
for
i
:=
0
;
i
<
b
.
N
;
i
++
{
for
i
:=
0
;
i
<
b
.
N
;
i
++
{
_
,
err
:=
xzlib
.
Decompress
(
zdata
,
nil
)
_
,
err
:=
xzlib
.
Decompress
(
zdata
)
if
err
!=
nil
{
if
err
!=
nil
{
b
.
Fatal
(
err
)
b
.
Fatal
(
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