2024-04-26 19:30:35 +00:00
|
|
|
//go:build !appengine
|
2024-02-18 10:42:21 +00:00
|
|
|
// +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
|
|
|
|
}
|