1// +build !appengine,!appenginevm
13// The reason for using *[]byte rather than []byte in parameters is an optimization. As of Go 1.6,
14// the compiler cannot perfectly inline the function when using a non-pointer slice. That is,
15// the non-pointer []byte parameter version is slower than if its function body is manually
16// inlined, whereas the pointer []byte version is equally fast to the manually inlined
17// version. Instruction count in assembly taken from "go tool compile" confirms this difference.
19// TODO: Remove hack after Go 1.7 release
21func equalStr(b *[]byte, s string) bool {
22 return *(*string)(unsafe.Pointer(b)) == s
25func parseFloat(b *[]byte) (float64, error) {
26 return strconv.ParseFloat(*(*string)(unsafe.Pointer(b)), 64)
29// A hack until issue golang/go#2632 is fixed.
30// See: https://github.com/golang/go/issues/2632
31func bytesToString(b *[]byte) string {
32 return *(*string)(unsafe.Pointer(b))
35func StringToBytes(s string) []byte {
36 b := make([]byte, 0, 0)
37 bh := (*reflect.SliceHeader)(unsafe.Pointer(&b))
38 sh := (*reflect.StringHeader)(unsafe.Pointer(&s))
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list