Keyboard Shortcuts

File
u :up to issue
m :publish + mail comments
M :edit review message
j / k :jump to file after / before current file
J / K :jump to next file with a comment after / before current file
Side-by-side diff
i :toggle intra-line diffs
e :expand all comments
c :collapse all comments
s :toggle showing all comments
n / p :next / previous diff chunk or comment
N / P :next / previous comment
<Up> / <Down> :next / previous line
<Enter> :respond to / edit current comment
d :mark current comment as done
Issue
u :up to list of issues
m :publish + mail comments
j / k :jump to patch after / before current patch
o / <Enter> :open current patch in side-by-side view
i :open current patch in unified diff view
Issue List
j / k :jump to issue after / before current issue
o / <Enter> :open current issue
# : close issue
Comment/message editing
<Ctrl> + s or <Ctrl> + Enter :save comment
<Esc> :cancel edit
Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(35)
Issues Repositories Search
Open Issues | Closed Issues | All Issues | Sign in with your Google Account to create issues and add comments

Issue 4817041: code review 4817041: io/ioutil: improve performance of ioutil.Discard (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
14 years, 5 months ago by msolo
Modified:
14 years, 5 months ago
Reviewers:
CC:
bradfitz, rsc, golang-dev
Visibility:
Public.
io/ioutil: improve performance of ioutil.Discard Fixes issue 2084.

Patch Set 1 #

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

Total comments: 2

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

Total comments: 2

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

Total comments: 2

Patch Set 5 : diff -r f2765b9aec9b https://go.googlecode.com/hg #

Total comments: 2

Patch Set 6 : diff -r f2765b9aec9b https://go.googlecode.com/hg #

Created: 14 years, 5 months ago
Download [raw] [tar.bz2]
Unified diffs Side-by-side diffs Delta from patch set Stats (+17 lines, -0 lines) Patch
M src/pkg/io/ioutil/ioutil.go View 1 2 3 4 5 1 chunk +17 lines, -0 lines 0 comments Download
Total messages: 13
|
msolo
Hello bradfitz@golang.org (cc: golang-dev@googlegroups.com), I'd like you to review this change to https://go.googlecode.com/hg
14 years, 5 months ago (2011年07月20日 20:13:39 UTC) #1
Hello bradfitz@golang.org (cc: golang-dev@googlegroups.com),
I'd like you to review this change to
https://go.googlecode.com/hg 
Sign in to reply to this message.
rsc
> + junk := blackHole[0:cap(blackHole)] > + readSize, err = r.Read(junk) you can just say ...
14 years, 5 months ago (2011年07月20日 20:17:56 UTC) #2
> +        junk := blackHole[0:cap(blackHole)]
> +        readSize, err = r.Read(junk)
you can just say
readSize, err = r.Read(blackHole)
there's no need for junk.
Sign in to reply to this message.
bradfitz
http://codereview.appspot.com/4817041/diff/2001/src/pkg/io/ioutil/ioutil.go File src/pkg/io/ioutil/ioutil.go (right): http://codereview.appspot.com/4817041/diff/2001/src/pkg/io/ioutil/ioutil.go#newcode122 src/pkg/io/ioutil/ioutil.go:122: return n, nil why is there a for loop ...
14 years, 5 months ago (2011年07月20日 20:21:49 UTC) #3
http://codereview.appspot.com/4817041/diff/2001/src/pkg/io/ioutil/ioutil.go
File src/pkg/io/ioutil/ioutil.go (right):
http://codereview.appspot.com/4817041/diff/2001/src/pkg/io/ioutil/ioutil.go#n...
src/pkg/io/ioutil/ioutil.go:122: return n, nil
why is there a for loop if you always exit on the first pass?
this line is repeated on line 125. just remove this and the for? but I suspect
you mean to actually loop and consume everything from r until an error, right?
Sign in to reply to this message.
msolo
Hello bradfitz@golang.org, rsc@golang.org (cc: golang-dev@googlegroups.com), Please take another look.
14 years, 5 months ago (2011年07月20日 20:34:04 UTC) #4
Hello bradfitz@golang.org, rsc@golang.org (cc: golang-dev@googlegroups.com),
Please take another look.
Sign in to reply to this message.
bradfitz
http://codereview.appspot.com/4817041/diff/7001/src/pkg/io/ioutil/ioutil.go File src/pkg/io/ioutil/ioutil.go (right): http://codereview.appspot.com/4817041/diff/7001/src/pkg/io/ioutil/ioutil.go#newcode114 src/pkg/io/ioutil/ioutil.go:114: readSize := 0 you could ditch this line too ...
14 years, 5 months ago (2011年07月20日 20:36:57 UTC) #5
http://codereview.appspot.com/4817041/diff/7001/src/pkg/io/ioutil/ioutil.go
File src/pkg/io/ioutil/ioutil.go (right):
http://codereview.appspot.com/4817041/diff/7001/src/pkg/io/ioutil/ioutil.go#n...
src/pkg/io/ioutil/ioutil.go:114: readSize := 0
you could ditch this line too and use := on line 116
http://codereview.appspot.com/4817041/diff/7001/src/pkg/io/ioutil/ioutil.go#n...
src/pkg/io/ioutil/ioutil.go:121: return n, nil
why is there a for loop if you always exit on the first pass?
this line is repeated on line 125. just remove this and the for? but I suspect
you mean to actually loop and consume everything from r until an error, right?
Sign in to reply to this message.
msolo
Hello bradfitz@golang.org, rsc@golang.org (cc: golang-dev@googlegroups.com), Please take another look.
14 years, 5 months ago (2011年07月20日 21:02:41 UTC) #6
Hello bradfitz@golang.org, rsc@golang.org (cc: golang-dev@googlegroups.com),
Please take another look.
Sign in to reply to this message.
msolo
http://codereview.appspot.com/4817041/diff/2001/src/pkg/io/ioutil/ioutil.go File src/pkg/io/ioutil/ioutil.go (right): http://codereview.appspot.com/4817041/diff/2001/src/pkg/io/ioutil/ioutil.go#newcode122 src/pkg/io/ioutil/ioutil.go:122: return n, nil Good catch. I've fixed the loop. ...
14 years, 5 months ago (2011年07月20日 21:03:42 UTC) #7
http://codereview.appspot.com/4817041/diff/2001/src/pkg/io/ioutil/ioutil.go
File src/pkg/io/ioutil/ioutil.go (right):
http://codereview.appspot.com/4817041/diff/2001/src/pkg/io/ioutil/ioutil.go#n...
src/pkg/io/ioutil/ioutil.go:122: return n, nil
Good catch. I've fixed the loop.
On 2011年07月20日 20:21:49, bradfitz wrote:
> why is there a for loop if you always exit on the first pass?
> 
> this line is repeated on line 125. just remove this and the for? but I
suspect
> you mean to actually loop and consume everything from r until an error, right?
Sign in to reply to this message.
bradfitz
http://codereview.appspot.com/4817041/diff/10001/src/pkg/io/ioutil/ioutil.go File src/pkg/io/ioutil/ioutil.go (right): http://codereview.appspot.com/4817041/diff/10001/src/pkg/io/ioutil/ioutil.go#newcode114 src/pkg/io/ioutil/ioutil.go:114: readSize := 0 either ditch this line, or... http://codereview.appspot.com/4817041/diff/10001/src/pkg/io/ioutil/ioutil.go#newcode122 ...
14 years, 5 months ago (2011年07月20日 21:12:14 UTC) #8
http://codereview.appspot.com/4817041/diff/10001/src/pkg/io/ioutil/ioutil.go
File src/pkg/io/ioutil/ioutil.go (right):
http://codereview.appspot.com/4817041/diff/10001/src/pkg/io/ioutil/ioutil.go#...
src/pkg/io/ioutil/ioutil.go:114: readSize := 0
either ditch this line, or...
http://codereview.appspot.com/4817041/diff/10001/src/pkg/io/ioutil/ioutil.go#...
src/pkg/io/ioutil/ioutil.go:122: return n, err
.. or just make this line be "return" (and unident it, killing the else block)
You seem to be going out of your way to avoid using := on line 116, but then
you're not taking advantage of it.
Sign in to reply to this message.
msolo
Hello bradfitz@golang.org, rsc@golang.org (cc: golang-dev@googlegroups.com), Please take another look.
14 years, 5 months ago (2011年07月20日 21:15:19 UTC) #9
Hello bradfitz@golang.org, rsc@golang.org (cc: golang-dev@googlegroups.com),
Please take another look.
Sign in to reply to this message.
bradfitz
http://codereview.appspot.com/4817041/diff/14001/src/pkg/io/ioutil/ioutil.go File src/pkg/io/ioutil/ioutil.go (right): http://codereview.appspot.com/4817041/diff/14001/src/pkg/io/ioutil/ioutil.go#newcode120 src/pkg/io/ioutil/ioutil.go:120: return n, nil // err is EOF, so return ...
14 years, 5 months ago (2011年07月20日 21:17:16 UTC) #10
http://codereview.appspot.com/4817041/diff/14001/src/pkg/io/ioutil/ioutil.go
File src/pkg/io/ioutil/ioutil.go (right):
http://codereview.appspot.com/4817041/diff/14001/src/pkg/io/ioutil/ioutil.go#...
src/pkg/io/ioutil/ioutil.go:120: return n, nil // err is EOF, so return nil
explicitly
err = nil
(no comment necessary, because that statement is more explicit)
http://codereview.appspot.com/4817041/diff/14001/src/pkg/io/ioutil/ioutil.go#...
src/pkg/io/ioutil/ioutil.go:122: return n, err
return
(no arguments needed, because you're using the same n and err already)
Sign in to reply to this message.
msolo
Hello bradfitz@golang.org, rsc@golang.org (cc: golang-dev@googlegroups.com), Please take another look.
14 years, 5 months ago (2011年07月20日 21:20:36 UTC) #11
Hello bradfitz@golang.org, rsc@golang.org (cc: golang-dev@googlegroups.com),
Please take another look.
Sign in to reply to this message.
bradfitz
LGTM
14 years, 5 months ago (2011年07月20日 21:27:13 UTC) #12
LGTM
Sign in to reply to this message.
bradfitz
*** Submitted as http://code.google.com/p/go/source/detail?r=13faa632ba3a *** io/ioutil: improve performance of ioutil.Discard Fixes issue 2084. R=bradfitz, rsc ...
14 years, 5 months ago (2011年07月20日 21:34:57 UTC) #13
*** Submitted as http://code.google.com/p/go/source/detail?r=13faa632ba3a ***
io/ioutil: improve performance of ioutil.Discard
Fixes issue 2084.
R=bradfitz, rsc
CC=golang-dev
http://codereview.appspot.com/4817041
Committer: Brad Fitzpatrick <bradfitz@golang.org>
Sign in to reply to this message.
|
This is Rietveld f62528b

AltStyle によって変換されたページ (->オリジナル) /