]> Cypherpunks repositories - gostls13.git/commit
database/sql: avoiding fmt.Sprintf while scanning, avoid allocs with RawBytes
authorBrad Fitzpatrick <bradfitz@golang.org>
Fri, 10 Jan 2014 20:19:36 +0000 (12:19 -0800)
committerBrad Fitzpatrick <bradfitz@golang.org>
Fri, 10 Jan 2014 20:19:36 +0000 (12:19 -0800)
commit258ed3f2265a41a46e936e884d8afd6e6f646973
tree3b57fa17c1c5e297a2c676804009709b9ea14bb8
parent3b8dfc32b3e75f128fa896c1bb9a70fca2da6dcb
database/sql: avoiding fmt.Sprintf while scanning, avoid allocs with RawBytes

A user reported heavy contention on fmt's printer cache. Avoid
fmt.Sprint. We have to do reflection anyway, and there was
already an asString function to use strconv, so use it.

This CL also eliminates a redundant allocation + copy when
scanning into *[]byte (avoiding the intermediate string)
and avoids an extra alloc when assigning to a caller's RawBytes
(trying to reuse the caller's memory).

Fixes #7086

R=golang-codereviews, nightlyone
CC=golang-codereviews
https://golang.org/cl/50240044
src/pkg/database/sql/convert.go
src/pkg/database/sql/convert_test.go