From a689c20777ed9ad661f3c9e4017ebdca23bbba3c Mon Sep 17 00:00:00 2001 From: Vladimir Mihailenco Date: Fri, 4 Sep 2015 13:30:37 +0300 Subject: [PATCH] Enable unsafe. --- unsafe.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/unsafe.go b/unsafe.go index 75465d4..3cd8d1c 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)) }