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 po
(b *[]byte, s string)
| 20 | // TODO: Remove hack after Go 1.7 release |
| 21 | // |
| 22 | func equalStr(b *[]byte, s string) bool { |
| 23 | return *(*string)(unsafe.Pointer(b)) == s |
| 24 | } |
| 25 | |
| 26 | func parseFloat(b *[]byte) (float64, error) { |
| 27 | return strconv.ParseFloat(*(*string)(unsafe.Pointer(b)), 64) |
nothing calls this directly
no outgoing calls
no test coverage detected