summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/philhofer/fwd/writer_unsafe.go
blob: a0bf453b394c5e75ae6913002b9b50a6827071f9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// +build !appengine

package fwd

import (
	"reflect"
	"unsafe"
)

// unsafe cast string as []byte
func unsafestr(b string) []byte {
	l := len(b)
	return *(*[]byte)(unsafe.Pointer(&reflect.SliceHeader{
		Len:  l,
		Cap:  l,
		Data: (*reflect.StringHeader)(unsafe.Pointer(&b)).Data,
	}))
}