pki/vendor/github.com/valyala/fasttemplate/unsafe.go
Paul Lecuq a7d4f06285
All checks were successful
continuous-integration/drone/push Build is passing
ready for public beta
2020-11-25 20:36:07 +01:00

22 lines
375 B
Go

// +build !appengine
package fasttemplate
import (
"reflect"
"unsafe"
)
func unsafeBytes2String(b []byte) string {
return *(*string)(unsafe.Pointer(&b))
}
func unsafeString2Bytes(s string) (b []byte) {
sh := (*reflect.StringHeader)(unsafe.Pointer(&s))
bh := (*reflect.SliceHeader)(unsafe.Pointer(&b))
bh.Data = sh.Data
bh.Cap = sh.Len
bh.Len = sh.Len
return b
}