Skip to content
Open
Show file tree
Hide file tree
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
7 changes: 3 additions & 4 deletions murmur128.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package murmur3

import (
//"encoding/binary"
"encoding/binary"
"hash"
"math/bits"
"unsafe"
)

const (
Expand Down Expand Up @@ -65,8 +64,8 @@ func (d *digest128) bmix(p []byte) (tail []byte) {

nblocks := len(p) / 16
for i := 0; i < nblocks; i++ {
t := (*[2]uint64)(unsafe.Pointer(&p[i*16]))
k1, k2 := t[0], t[1]
k1 := binary.LittleEndian.Uint64(p[i*16:])
k2 := binary.LittleEndian.Uint64(p[i*16+8:])

k1 *= c1_128
k1 = bits.RotateLeft64(k1, 31)
Expand Down
13 changes: 4 additions & 9 deletions murmur32.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ package murmur3
// http://code.google.com/p/guava-libraries/source/browse/guava/src/com/google/common/hash/Murmur3_32HashFunction.java

import (
"encoding/binary"
"hash"
"math/bits"
"unsafe"
)

// Make sure interfaces are correctly implemented.
Expand Down Expand Up @@ -53,7 +53,7 @@ func (d *digest32) bmix(p []byte) (tail []byte) {

nblocks := len(p) / 4
for i := 0; i < nblocks; i++ {
k1 := *(*uint32)(unsafe.Pointer(&p[i*4]))
k1 := binary.LittleEndian.Uint32(p[i*4:])

k1 *= c1_32
k1 = bits.RotateLeft32(k1, 15)
Expand Down Expand Up @@ -115,13 +115,8 @@ func Sum32WithSeed(data []byte, seed uint32) uint32 {
h1 := seed

nblocks := len(data) / 4
var p uintptr
if len(data) > 0 {
p = uintptr(unsafe.Pointer(&data[0]))
}
p1 := p + uintptr(4*nblocks)
for ; p < p1; p += 4 {
k1 := *(*uint32)(unsafe.Pointer(p))
for i := 0; i < nblocks; i++ {
k1 := binary.LittleEndian.Uint32(data[i*4:])

k1 *= c1_32
k1 = bits.RotateLeft32(k1, 15)
Expand Down