diff options
author | Damian Gryski <[email protected]> | 2024-10-18 10:25:04 -0700 |
---|---|---|
committer | Damian Gryski <[email protected]> | 2024-10-19 15:16:30 -0700 |
commit | 0dfa57ea042f935183746f98dc6751d8e38d88d4 (patch) | |
tree | f7392658f34add6ed8dde72af9c1c5e9024170d9 | |
parent | 2f9e39e21c8d3ff2f1ee991bd9492da2e37162c3 (diff) | |
download | tinygo-0dfa57ea042f935183746f98dc6751d8e38d88d4.tar.gz tinygo-0dfa57ea042f935183746f98dc6751d8e38d88d4.zip |
runtime: use unsafe.Slice in tsip code
-rw-r--r-- | src/runtime/memhash_tsip.go | 24 |
1 files changed, 2 insertions, 22 deletions
diff --git a/src/runtime/memhash_tsip.go b/src/runtime/memhash_tsip.go index a8829e052..607055bd5 100644 --- a/src/runtime/memhash_tsip.go +++ b/src/runtime/memhash_tsip.go @@ -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 } @@ -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) @@ -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) |