Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(279)

Issue 50240044: code review 50240044: database/sql: avoiding fmt.Sprintf while scanning, avoi... (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
10 years, 3 months ago by bradfitz
Modified:
10 years, 3 months ago
Reviewers:
ioe
CC:
golang-codereviews, ioe
Visibility:
Public.

Description

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 Issue 7086

Patch Set 1 #

Patch Set 2 : diff -r e4b3e3c1edda https://go.googlecode.com/hg/ #

Patch Set 3 : diff -r e4b3e3c1edda https://go.googlecode.com/hg/ #

Patch Set 4 : diff -r b4280f484ccf https://go.googlecode.com/hg/ #

Unified diffs Side-by-side diffs Delta from patch set Stats (+85 lines, -13 lines) Patch
M src/pkg/database/sql/convert.go View 1 2 2 chunks +37 lines, -13 lines 0 comments Download
M src/pkg/database/sql/convert_test.go View 1 2 1 chunk +48 lines, -0 lines 0 comments Download

Messages

Total messages: 3
bradfitz
Hello golang-codereviews@googlegroups.com, I'd like you to review this change to https://go.googlecode.com/hg/
10 years, 3 months ago (2014-01-10 00:03:59 UTC) #1
ioe
LGTM
10 years, 3 months ago (2014-01-10 19:47:50 UTC) #2
bradfitz
10 years, 3 months ago (2014-01-10 20:19:39 UTC) #3
*** Submitted as https://code.google.com/p/go/source/detail?r=60dd219ea8e3 ***

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 Issue 7086

R=golang-codereviews, nightlyone
CC=golang-codereviews
https://codereview.appspot.com/50240044
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b