5
0
mirror of https://github.com/cwinfo/matterbridge.git synced 2024-12-28 14:55:38 +00:00
matterbridge/vendor/github.com/valyala/fasttemplate/unsafe.go

22 lines
375 B
Go
Raw Normal View History

2017-06-05 22:01:05 +00:00
// +build !appengine
2017-02-18 22:00:46 +00:00
package fasttemplate
import (
"reflect"
"unsafe"
)
func unsafeBytes2String(b []byte) string {
return *(*string)(unsafe.Pointer(&b))
}
2020-09-04 21:29:13 +00:00
func unsafeString2Bytes(s string) (b []byte) {
2017-02-18 22:00:46 +00:00
sh := (*reflect.StringHeader)(unsafe.Pointer(&s))
2020-09-04 21:29:13 +00:00
bh := (*reflect.SliceHeader)(unsafe.Pointer(&b))
bh.Data = sh.Data
bh.Cap = sh.Len
bh.Len = sh.Len
return b
2017-02-18 22:00:46 +00:00
}