We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 8cbd4b0 commit a6906f1Copy full SHA for a6906f1
1 file changed
hash.go
@@ -1,7 +1,7 @@
1
package bloom
2
3
import (
4
- "unsafe"
+ "encoding/binary"
5
)
6
7
// MurmurHash3 implementation adapted from Sébastien Paolacci
@@ -31,12 +31,9 @@ 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
- // Without unsafe:
37
- // j := 16 * i
38
- // k1 := binary.LittleEndian.Uint64(p[j : j+8])
39
- // k2 := binary.LittleEndian.Uint64(p[j+8 : j+16])
+ j := 16 * i
+ k1 := binary.LittleEndian.Uint64(p[j : j+8])
+ k2 := binary.LittleEndian.Uint64(p[j+8 : j+16])
40
k1 *= c1
41
k1 = (k1 << 31) | (k1 >> 33)
42
k1 *= c2
0 commit comments