We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 08eaa09 commit bea3453Copy full SHA for bea3453
1 file changed
hash.go
@@ -1,7 +1,7 @@
1
package bloom
2
3
import (
4
- "encoding/binary"
+ "unsafe"
5
)
6
7
// MurmurHash3 implementation adapted from Sébastien Paolacci
@@ -31,11 +31,12 @@ func (d *digest) bmix(p []byte) (tail []byte) {
31
h1, h2 := d.h1, d.h2
32
nblocks := len(p) / 16
33
for i := 0; i < nblocks; i++ {
34
- //t := (*[2]uint64)(unsafe.Pointer(&p[i*16]))
35
- //k1, k2 := t[0], t[1]
36
- j := 16 * i
37
- k1 := binary.LittleEndian.Uint64(p[j : j+8])
38
- k2 := binary.LittleEndian.Uint64(p[j+8 : j+16])
+ t := (*[2]uint64)(unsafe.Pointer(&p[i*16]))
+ k1, k2 := t[0], t[1]
+ // Without unsafe:
+ // j := 16 * i
+ // k1 := binary.LittleEndian.Uint64(p[j : j+8])
39
+ // k2 := binary.LittleEndian.Uint64(p[j+8 : j+16])
40
k1 *= c1
41
k1 = (k1 << 31) | (k1 >> 33)
42
k1 *= c2
0 commit comments