• Brad Fitzpatrick's avatar
    database/sql: avoiding fmt.Sprintf while scanning, avoid allocs with RawBytes · 258ed3f2
    Brad Fitzpatrick authored
    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
    258ed3f2
convert.go 7.13 KB