VictoriaMetrics/vendor/github.com/valyala/quicktemplate/util_noappengine.go

23 lines
423 B
Go
Raw Normal View History

//go:build !appengine && !appenginevm
2019-05-22 21:16:55 +00:00
// +build !appengine,!appenginevm
package quicktemplate
import (
"reflect"
"unsafe"
)
func unsafeStrToBytes(s string) (b []byte) {
2019-05-22 21:16:55 +00:00
sh := (*reflect.StringHeader)(unsafe.Pointer(&s))
bh := (*reflect.SliceHeader)(unsafe.Pointer(&b))
bh.Data = sh.Data
bh.Len = sh.Len
bh.Cap = sh.Len
return b
2019-05-22 21:16:55 +00:00
}
func unsafeBytesToStr(z []byte) string {
return *(*string)(unsafe.Pointer(&z))
}