diff options
author | Damian Gryski <[email protected]> | 2024-10-18 10:26:26 -0700 |
---|---|---|
committer | Damian Gryski <[email protected]> | 2024-10-19 15:16:30 -0700 |
commit | 23d3a31107b16fddf16e8cea623caea35e05404c (patch) | |
tree | abc12845501cf0e594554e3c0613c3aefce62b50 | |
parent | 0dfa57ea042f935183746f98dc6751d8e38d88d4 (diff) | |
download | tinygo-23d3a31107b16fddf16e8cea623caea35e05404c.tar.gz tinygo-23d3a31107b16fddf16e8cea623caea35e05404c.zip |
runtime: use unsafe.Slice for leveldb code
-rw-r--r-- | src/runtime/memhash_leveldb.go | 19 |
1 files changed, 1 insertions, 18 deletions
diff --git a/src/runtime/memhash_leveldb.go b/src/runtime/memhash_leveldb.go index f57c9cf93..2e7557bb3 100644 --- a/src/runtime/memhash_leveldb.go +++ b/src/runtime/memhash_leveldb.go @@ -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 { @@ -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)) |