diff options
Diffstat (limited to 'vendor/github.com/valyala/fasttemplate/unsafe.go')
-rw-r--r-- | vendor/github.com/valyala/fasttemplate/unsafe.go | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/vendor/github.com/valyala/fasttemplate/unsafe.go b/vendor/github.com/valyala/fasttemplate/unsafe.go index 0498248f..1020ca38 100644 --- a/vendor/github.com/valyala/fasttemplate/unsafe.go +++ b/vendor/github.com/valyala/fasttemplate/unsafe.go @@ -11,12 +11,11 @@ func unsafeBytes2String(b []byte) string { return *(*string)(unsafe.Pointer(&b)) } -func unsafeString2Bytes(s string) []byte { +func unsafeString2Bytes(s string) (b []byte) { sh := (*reflect.StringHeader)(unsafe.Pointer(&s)) - bh := reflect.SliceHeader{ - Data: sh.Data, - Len: sh.Len, - Cap: sh.Len, - } - return *(*[]byte)(unsafe.Pointer(&bh)) + bh := (*reflect.SliceHeader)(unsafe.Pointer(&b)) + bh.Data = sh.Data + bh.Cap = sh.Len + bh.Len = sh.Len + return b } |