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
462a6eb4
Unverified
Commit
462a6eb4
authored
Oct 07, 2019
by
Jakub Sztandera
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleanup buf usage
License: MIT Signed-off-by:
Jakub Sztandera
<
kubuxu@protocol.ai
>
parent
5ac3082b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
8 deletions
+7
-8
buzhash.go
buzhash.go
+7
-8
No files found.
buzhash.go
View file @
462a6eb4
...
...
@@ -37,14 +37,13 @@ func (b *Buzhash) NextBytes() ([]byte, error) {
return
nil
,
b
.
err
}
buf
:=
b
.
buf
n
,
err
:=
io
.
ReadFull
(
b
.
r
,
buf
[
b
.
n
:
])
n
,
err
:=
io
.
ReadFull
(
b
.
r
,
b
.
buf
[
b
.
n
:
])
if
err
!=
nil
{
if
err
==
io
.
ErrUnexpectedEOF
||
err
==
io
.
EOF
{
if
b
.
n
+
n
<
buzMin
{
b
.
err
=
io
.
EOF
res
:=
make
([]
byte
,
b
.
n
+
n
)
copy
(
res
,
buf
)
copy
(
res
,
b
.
buf
)
pool
.
Put
(
b
.
buf
)
b
.
buf
=
nil
...
...
@@ -52,7 +51,7 @@ func (b *Buzhash) NextBytes() ([]byte, error) {
}
}
else
{
b
.
err
=
err
pool
.
Put
(
buf
)
pool
.
Put
(
b
.
buf
)
b
.
buf
=
nil
return
nil
,
err
}
...
...
@@ -64,21 +63,21 @@ func (b *Buzhash) NextBytes() ([]byte, error) {
for
;
i
<
buzMin
;
i
++
{
state
=
bits
.
RotateLeft32
(
state
,
1
)
state
=
state
^
bytehash
[
buf
[
i
]]
state
=
state
^
bytehash
[
b
.
buf
[
i
]]
}
if
b
.
n
+
n
>
len
(
buf
)
{
if
b
.
n
+
n
>
len
(
b
.
buf
)
{
panic
(
"this is impossible, but gives +9 to performance"
)
}
for
;
state
&
buzMask
!=
0
&&
i
<
b
.
n
+
n
;
i
++
{
state
=
bits
.
RotateLeft32
(
state
,
1
)
^
bytehash
[
buf
[
i
-
32
]]
^
bytehash
[
buf
[
i
]]
state
=
bits
.
RotateLeft32
(
state
,
1
)
^
bytehash
[
b
.
buf
[
i
-
32
]]
^
bytehash
[
b
.
buf
[
i
]]
}
res
:=
make
([]
byte
,
i
)
copy
(
res
,
b
.
buf
)
b
.
n
=
copy
(
b
.
buf
,
buf
[
i
:
b
.
n
+
n
])
b
.
n
=
copy
(
b
.
buf
,
b
.
buf
[
i
:
b
.
n
+
n
])
return
res
,
nil
}
...
...
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