Debian Codegraph @

qsort/unsafe.go

raw
1 package qsort
2
3 import "unsafe"
4
5 func unsafeBytesTo64(b []byte) []uint64 {
6 return *(*[]uint64)(unsafe.Pointer(cast(b, 8)))
7 }
8
9 func unsafeBytesTo128(b []byte) []uint128 {
10 return *(*[]uint128)(unsafe.Pointer(cast(b, 16)))
11 }
12
13 func unsafeBytesTo192(b []byte) []uint192 {
14 return *(*[]uint192)(unsafe.Pointer(cast(b, 24)))
15 }
16
17 func unsafeBytesTo256(b []byte) []uint256 {
18 return *(*[]uint256)(unsafe.Pointer(cast(b, 32)))
19 }
20
21 func cast(b []byte, size int) *sliceHeader {
22 return &sliceHeader{
23 Data: *(*unsafe.Pointer)(unsafe.Pointer(&b)),
24 Len: len(b) / size,
25 Cap: len(b) / size,
26 }
27 }
28
29 type sliceHeader struct {
30 Data unsafe.Pointer
31 Len int
32 Cap int
33 }