mirror of
https://github.com/cwinfo/matterbridge.git
synced 2024-11-14 21:10:28 +00:00
21 lines
356 B
Go
21 lines
356 B
Go
package fasttemplate
|
|
|
|
import (
|
|
"reflect"
|
|
"unsafe"
|
|
)
|
|
|
|
func unsafeBytes2String(b []byte) string {
|
|
return *(*string)(unsafe.Pointer(&b))
|
|
}
|
|
|
|
func unsafeString2Bytes(s string) []byte {
|
|
sh := (*reflect.StringHeader)(unsafe.Pointer(&s))
|
|
bh := reflect.SliceHeader{
|
|
Data: sh.Data,
|
|
Len: sh.Len,
|
|
Cap: sh.Len,
|
|
}
|
|
return *(*[]byte)(unsafe.Pointer(&bh))
|
|
}
|