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
|
|
|
}
|