mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-24 03:06:48 +01:00
23 lines
388 B
Go
23 lines
388 B
Go
|
// +build !appengine,!appenginevm
|
||
|
|
||
|
package quicktemplate
|
||
|
|
||
|
import (
|
||
|
"reflect"
|
||
|
"unsafe"
|
||
|
)
|
||
|
|
||
|
func unsafeStrToBytes(s string) []byte {
|
||
|
sh := (*reflect.StringHeader)(unsafe.Pointer(&s))
|
||
|
bh := reflect.SliceHeader{
|
||
|
Data: sh.Data,
|
||
|
Len: sh.Len,
|
||
|
Cap: sh.Len,
|
||
|
}
|
||
|
return *(*[]byte)(unsafe.Pointer(&bh))
|
||
|
}
|
||
|
|
||
|
func unsafeBytesToStr(z []byte) string {
|
||
|
return *(*string)(unsafe.Pointer(&z))
|
||
|
}
|