From 5e74f5029b15decee67095532a5c60cb98bbea52 Mon Sep 17 00:00:00 2001 From: Julien Schmidt Date: Mon, 25 Mar 2013 17:43:30 -0700 Subject: 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 --- src/pkg/database/sql/sql.go | 18 ------------------ 1 file changed, 18 deletions(-) (limited to 'src/pkg/database/sql/sql.go') diff --git a/src/pkg/database/sql/sql.go b/src/pkg/database/sql/sql.go index 236e2c095d..d89aa59792 100644 --- a/src/pkg/database/sql/sql.go +++ b/src/pkg/database/sql/sql.go @@ -1301,24 +1301,6 @@ func (rs *Rows) Scan(dest ...interface{}) error { return fmt.Errorf("sql: Scan error on column index %d: %v", i, err) } } - for _, dp := range dest { - b, ok := dp.(*[]byte) - if !ok { - continue - } - if *b == nil { - // If the []byte is now nil (for a NULL value), - // don't fall through to below which would - // turn it into a non-nil 0-length byte slice - continue - } - if _, ok = dp.(*RawBytes); ok { - continue - } - clone := make([]byte, len(*b)) - copy(clone, *b) - *b = clone - } return nil } -- cgit v1.3