diff --git a/b2s_new.go b/b2s_new.go index 2cbf5e3391..2f7d6f7e62 100644 --- a/b2s_new.go +++ b/b2s_new.go @@ -8,9 +8,5 @@ import "unsafe" // b2s converts byte slice to a string without memory allocation. // See https://groups.google.com/forum/#!msg/Golang-Nuts/ENgbUzYvCuU/90yGx7GUAgAJ . func b2s(b []byte) string { - if len(b) == 0 { - return "" - } - - return unsafe.String(&b[0], len(b)) + return unsafe.String(unsafe.SliceData(b), len(b)) }