mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
database/sql: optimized []byte copy + []byte(nil) -> *interface fix
Make the copy directly in the convert switch instead of an extra loop. Also stops converting nil-[]byte to zero-[]byte when assigning to *interface R=golang-dev, bradfitz CC=golang-dev https://golang.org/cl/7962044
This commit is contained in:
parent
4529c047b8
commit
5e74f5029b
3 changed files with 20 additions and 23 deletions
|
|
@ -143,6 +143,7 @@ var conversionTests = []conversionTest{
|
|||
{s: []byte("byteslice"), d: &scaniface, wantiface: []byte("byteslice")},
|
||||
{s: true, d: &scaniface, wantiface: true},
|
||||
{s: nil, d: &scaniface},
|
||||
{s: []byte(nil), d: &scaniface, wantiface: []byte(nil)},
|
||||
}
|
||||
|
||||
func intPtrValue(intptr interface{}) interface{} {
|
||||
|
|
@ -221,7 +222,7 @@ func TestConversions(t *testing.T) {
|
|||
}
|
||||
if srcBytes, ok := ct.s.([]byte); ok {
|
||||
dstBytes := (*ifptr).([]byte)
|
||||
if &dstBytes[0] == &srcBytes[0] {
|
||||
if len(srcBytes) > 0 && &dstBytes[0] == &srcBytes[0] {
|
||||
errf("copy into interface{} didn't copy []byte data")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue