From abb85b0fb8a7f0ef7551677888d8d674d153c991 Mon Sep 17 00:00:00 2001 From: Vladimir Mihailenco Date: Mon, 15 Jan 2018 16:15:20 +0200 Subject: [PATCH] Remove StringToBytes --- internal/proto/scan.go | 5 +++-- internal/safe.go | 4 ---- internal/unsafe.go | 10 ---------- 3 files changed, 3 insertions(+), 16 deletions(-) diff --git a/internal/proto/scan.go b/internal/proto/scan.go index 03c8b59..0329ffd 100644 --- a/internal/proto/scan.go +++ b/internal/proto/scan.go @@ -123,8 +123,9 @@ func ScanSlice(data []string, slice interface{}) error { next := internal.MakeSliceNextElemFunc(v) for i, s := range data { elem := next() - if err := Scan(internal.StringToBytes(s), elem.Addr().Interface()); err != nil { - return fmt.Errorf("redis: ScanSlice(index=%d value=%q) failed: %s", i, s, err) + if err := Scan([]byte(s), elem.Addr().Interface()); err != nil { + err = fmt.Errorf("redis: ScanSlice index=%d value=%q failed: %s", i, s, err) + return err } } diff --git a/internal/safe.go b/internal/safe.go index 870fe54..dc5f4cc 100644 --- a/internal/safe.go +++ b/internal/safe.go @@ -5,7 +5,3 @@ package internal func BytesToString(b []byte) string { return string(b) } - -func StringToBytes(s string) []byte { - return []byte(s) -} diff --git a/internal/unsafe.go b/internal/unsafe.go index a54a34a..3ae48c1 100644 --- a/internal/unsafe.go +++ b/internal/unsafe.go @@ -10,13 +10,3 @@ import ( func BytesToString(b []byte) string { return *(*string)(unsafe.Pointer(&b)) } - -// StringToBytes converts string to byte slice. -func StringToBytes(s string) []byte { - return *(*[]byte)(unsafe.Pointer( - &struct { - string - Cap int - }{s,len(s)}, - )) -}