Source File
bytes_unsafe.go
Belonging Package
github.com/buger/jsonparser
// +build !appengine,!appenginevmpackage jsonparserimport ()//// The reason for using *[]byte rather than []byte in parameters is an optimization. As of Go 1.6,// the compiler cannot perfectly inline the function when using a non-pointer slice. That is,// the non-pointer []byte parameter version is slower than if its function body is manually// inlined, whereas the pointer []byte version is equally fast to the manually inlined// version. Instruction count in assembly taken from "go tool compile" confirms this difference.//// TODO: Remove hack after Go 1.7 release//func equalStr( *[]byte, string) bool {return *(*string)(unsafe.Pointer()) ==}func parseFloat( *[]byte) (float64, error) {return strconv.ParseFloat(*(*string)(unsafe.Pointer()), 64)}// A hack until issue golang/go#2632 is fixed.// See: https://github.com/golang/go/issues/2632func bytesToString( *[]byte) string {return *(*string)(unsafe.Pointer())}func ( string) []byte {:= make([]byte, 0, 0):= (*reflect.SliceHeader)(unsafe.Pointer(&)):= (*reflect.StringHeader)(unsafe.Pointer(&)).Data = .Data.Cap = .Len.Len = .Lenruntime.KeepAlive()return}
![]() |
The pages are generated with Golds v0.8.2. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |