Skip to content
Merged
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
19 changes: 1 addition & 18 deletions src/runtime/memhash_leveldb.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,6 @@ import (
"unsafe"
)

func ptrToSlice(ptr unsafe.Pointer, n uintptr) []byte {
var p []byte

type _bslice struct {
ptr *byte
len uintptr
cap uintptr
}

pslice := (*_bslice)(unsafe.Pointer(&p))
pslice.ptr = (*byte)(ptr)
pslice.cap = n
pslice.len = n

return p
}

// leveldb hash
func hash32(ptr unsafe.Pointer, n, seed uintptr) uint32 {

Expand All @@ -41,7 +24,7 @@ func hash32(ptr unsafe.Pointer, n, seed uintptr) uint32 {
m = 0xc6a4a793
)

b := ptrToSlice(ptr, n)
b := unsafe.Slice((*byte)(ptr), n)

h := uint32(lseed^seed) ^ uint32(uint(len(b))*uint(m))

Expand Down
24 changes: 2 additions & 22 deletions src/runtime/memhash_tsip.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,6 @@ import (
"unsafe"
)

func ptrToSlice(ptr unsafe.Pointer, n uintptr) []byte {
var p []byte

type _bslice struct {
ptr *byte
len uintptr
cap uintptr
}

pslice := (*_bslice)(unsafe.Pointer(&p))
pslice.ptr = (*byte)(ptr)
pslice.cap = n
pslice.len = n

return p
}

type sip struct {
v0, v1 uint64
}
Expand All @@ -45,8 +28,7 @@ func (s *sip) round() {
}

func hash64(ptr unsafe.Pointer, n uintptr, seed uintptr) uint64 {

p := ptrToSlice(ptr, n)
p := unsafe.Slice((*byte)(ptr), n)

k0 := uint64(seed)
k1 := uint64(0)
Expand Down Expand Up @@ -117,9 +99,7 @@ func (s *sip32) round() {
}

func hash32(ptr unsafe.Pointer, n uintptr, seed uintptr) uint32 {
// TODO(dgryski): replace this messiness with unsafe.Slice when we can use 1.17 features

p := ptrToSlice(ptr, n)
p := unsafe.Slice((*byte)(ptr), n)

k0 := uint32(seed)
k1 := uint32(seed >> 32)
Expand Down
Loading