diff --git a/unsafe.go b/unsafe.go index 75465d43..3cd8d1c1 100644 --- a/unsafe.go +++ b/unsafe.go @@ -2,6 +2,13 @@ package redis +import ( + "reflect" + "unsafe" +) + func bytesToString(b []byte) string { - return string(b) + bytesHeader := (*reflect.SliceHeader)(unsafe.Pointer(&b)) + strHeader := reflect.StringHeader{bytesHeader.Data, bytesHeader.Len} + return *(*string)(unsafe.Pointer(&strHeader)) }