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
cc99d742
Unverified
Commit
cc99d742
authored
Nov 06, 2019
by
Steven Allen
Committed by
GitHub
Nov 06, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #17 from ipfs/feat/plus-9
Improve performance of buzhash
parents
21b0c066
79bdab24
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
5 deletions
+21
-5
buzhash.go
buzhash.go
+21
-5
No files found.
buzhash.go
View file @
cc99d742
...
...
@@ -61,17 +61,33 @@ func (b *Buzhash) NextBytes() ([]byte, error) {
var
state
uint32
=
0
if
buzMin
>
len
(
b
.
buf
)
{
panic
(
"this is impossible"
)
}
for
;
i
<
buzMin
;
i
++
{
state
=
bits
.
RotateLeft32
(
state
,
1
)
state
=
state
^
bytehash
[
b
.
buf
[
i
]]
}
if
b
.
n
+
n
>
len
(
b
.
buf
)
{
panic
(
"this is impossible, but gives +9 to performance"
)
}
{
max
:=
b
.
n
+
n
-
32
-
1
for
;
state
&
buzMask
!=
0
&&
i
<
b
.
n
+
n
;
i
++
{
state
=
bits
.
RotateLeft32
(
state
,
1
)
^
bytehash
[
b
.
buf
[
i
-
32
]]
^
bytehash
[
b
.
buf
[
i
]]
buf
:=
b
.
buf
bufshf
:=
b
.
buf
[
32
:
]
i
=
buzMin
-
32
_
=
buf
[
max
]
_
=
bufshf
[
max
]
for
;
i
<=
max
;
i
++
{
if
state
&
buzMask
==
0
{
break
}
state
=
bits
.
RotateLeft32
(
state
,
1
)
^
bytehash
[
buf
[
i
]]
^
bytehash
[
bufshf
[
i
]]
}
i
+=
32
}
res
:=
make
([]
byte
,
i
)
...
...
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