File tree Expand file tree Collapse file tree 1 file changed +2
-22
lines changed Expand file tree Collapse file tree 1 file changed +2
-22
lines changed Original file line number Diff line number Diff line change @@ -15,23 +15,6 @@ import (
15
15
"unsafe"
16
16
)
17
17
18
- func ptrToSlice (ptr unsafe.Pointer , n uintptr ) []byte {
19
- var p []byte
20
-
21
- type _bslice struct {
22
- ptr * byte
23
- len uintptr
24
- cap uintptr
25
- }
26
-
27
- pslice := (* _bslice )(unsafe .Pointer (& p ))
28
- pslice .ptr = (* byte )(ptr )
29
- pslice .cap = n
30
- pslice .len = n
31
-
32
- return p
33
- }
34
-
35
18
type sip struct {
36
19
v0 , v1 uint64
37
20
}
@@ -45,8 +28,7 @@ func (s *sip) round() {
45
28
}
46
29
47
30
func hash64 (ptr unsafe.Pointer , n uintptr , seed uintptr ) uint64 {
48
-
49
- p := ptrToSlice (ptr , n )
31
+ p := unsafe .Slice ((* byte )(ptr ), n )
50
32
51
33
k0 := uint64 (seed )
52
34
k1 := uint64 (0 )
@@ -117,9 +99,7 @@ func (s *sip32) round() {
117
99
}
118
100
119
101
func hash32 (ptr unsafe.Pointer , n uintptr , seed uintptr ) uint32 {
120
- // TODO(dgryski): replace this messiness with unsafe.Slice when we can use 1.17 features
121
-
122
- p := ptrToSlice (ptr , n )
102
+ p := unsafe .Slice ((* byte )(ptr ), n )
123
103
124
104
k0 := uint32 (seed )
125
105
k1 := uint32 (seed >> 32 )
You can’t perform that action at this time.
0 commit comments