2019-12-22 18:20:45 +01:00
|
|
|
// +build !appengine
|
|
|
|
|
|
|
|
package fasttemplate
|
|
|
|
|
|
|
|
import (
|
|
|
|
"reflect"
|
|
|
|
"unsafe"
|
|
|
|
)
|
|
|
|
|
|
|
|
func unsafeBytes2String(b []byte) string {
|
|
|
|
return *(*string)(unsafe.Pointer(&b))
|
|
|
|
}
|
|
|
|
|
2020-12-04 20:58:53 +01:00
|
|
|
func unsafeString2Bytes(s string) (b []byte) {
|
2019-12-22 18:20:45 +01:00
|
|
|
sh := (*reflect.StringHeader)(unsafe.Pointer(&s))
|
2020-12-04 20:58:53 +01:00
|
|
|
bh := (*reflect.SliceHeader)(unsafe.Pointer(&b))
|
|
|
|
bh.Data = sh.Data
|
|
|
|
bh.Cap = sh.Len
|
|
|
|
bh.Len = sh.Len
|
|
|
|
return b
|
2019-12-22 18:20:45 +01:00
|
|
|
}
|