Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions xxhash_other.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,17 @@ func Sum64(b []byte) uint64 {
v2 := prime2
v3 := uint64(0)
v4 := -primes[0]
for len(b) >= 64 {
v1 = round(v1, u64(b[0:8:len(b)]))
v2 = round(v2, u64(b[8:16:len(b)]))
v3 = round(v3, u64(b[16:24:len(b)]))
v4 = round(v4, u64(b[24:32:len(b)]))
v1 = round(v1, u64(b[32:40:len(b)]))
v2 = round(v2, u64(b[40:48:len(b)]))
v3 = round(v3, u64(b[48:56:len(b)]))
v4 = round(v4, u64(b[56:64:len(b)]))
b = b[64:len(b):len(b)]
}
for len(b) >= 32 {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can now become an if instead of a for. Same in writeBlocks.

v1 = round(v1, u64(b[0:8:len(b)]))
v2 = round(v2, u64(b[8:16:len(b)]))
Expand Down Expand Up @@ -64,6 +75,17 @@ func Sum64(b []byte) uint64 {
func writeBlocks(d *Digest, b []byte) int {
v1, v2, v3, v4 := d.v1, d.v2, d.v3, d.v4
n := len(b)
for len(b) >= 64 {
v1 = round(v1, u64(b[0:8:len(b)]))
v2 = round(v2, u64(b[8:16:len(b)]))
v3 = round(v3, u64(b[16:24:len(b)]))
v4 = round(v4, u64(b[24:32:len(b)]))
v1 = round(v1, u64(b[32:40:len(b)]))
v2 = round(v2, u64(b[40:48:len(b)]))
v3 = round(v3, u64(b[48:56:len(b)]))
v4 = round(v4, u64(b[56:64:len(b)]))
b = b[64:len(b):len(b)]
}
for len(b) >= 32 {
v1 = round(v1, u64(b[0:8:len(b)]))
v2 = round(v2, u64(b[8:16:len(b)]))
Expand Down