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

Issue 4306056: code review 4306056: strings: Map: avoid allocation when string is unchanged (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
14 years, 1 month ago by bradfitz
Modified:
14 years, 1 month ago
Reviewers:
CC:
r, rog, eh, rsc, golang-dev
Visibility:
Public.

Description

strings: Map: avoid allocation when string is unchanged This speeds up strings.ToLower, etc. before/after: strings_test.BenchmarkMapNoChanges 1000000 1013 ns/op strings_test.BenchmarkMapNoChanges 5000000 442 ns/op

Patch Set 1 #

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

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

Total comments: 4

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

Unified diffs Side-by-side diffs Delta from patch set Stats (+37 lines, -2 lines) Patch
M src/pkg/strings/strings.go View 1 2 3 2 chunks +15 lines, -2 lines 0 comments Download
M src/pkg/strings/strings_test.go View 1 2 chunks +22 lines, -0 lines 0 comments Download

Messages

Total messages: 24
bradfitz
Hello golang-dev@googlegroups.com (cc: golang-dev@googlegroups.com), I'd like you to review this change to https://go.googlecode.com/hg/
14 years, 1 month ago (2011-03-28 01:36:26 UTC) #1
r
http://codereview.appspot.com/4306056/diff/4001/src/pkg/strings/strings.go File src/pkg/strings/strings.go (right): http://codereview.appspot.com/4306056/diff/4001/src/pkg/strings/strings.go#newcode331 src/pkg/strings/strings.go:331: b = []byte(s) if mapping() throws away almost all ...
14 years, 1 month ago (2011-03-28 01:58:38 UTC) #2
bradfitz
http://codereview.appspot.com/4306056/diff/4001/src/pkg/strings/strings_test.go File src/pkg/strings/strings_test.go (right): http://codereview.appspot.com/4306056/diff/4001/src/pkg/strings/strings_test.go#newcode444 src/pkg/strings/strings_test.go:444: } On 2011/03/28 01:58:38, r wrote: > you don't ...
14 years, 1 month ago (2011-03-28 02:07:12 UTC) #3
r
maybe. i'm surprised, though. it's not much use to print the address of the header. ...
14 years, 1 month ago (2011-03-28 03:20:43 UTC) #4
bradfitz
On Sun, Mar 27, 2011 at 8:20 PM, Rob 'Commander' Pike <r@golang.org> wrote: > maybe. ...
14 years, 1 month ago (2011-03-28 03:39:58 UTC) #5
r
I've paged in what I was after. If you compute the address of the cap'th ...
14 years, 1 month ago (2011-03-28 03:55:59 UTC) #6
r
looks good but you should do the same transformation to bytes.Map, and in that test ...
14 years, 1 month ago (2011-03-28 03:59:53 UTC) #7
bradfitz
On Sun, Mar 27, 2011 at 8:55 PM, Rob 'Commander' Pike <r@golang.org> wrote: ... > ...
14 years, 1 month ago (2011-03-28 04:00:55 UTC) #8
bradfitzgoog
Oh, wow, there's a lot of stuff in package bytes that I've never used. On ...
14 years, 1 month ago (2011-03-28 04:02:22 UTC) #9
r
The test seems ungainly is what I meant. I wasn't impugning the Map function. -rob
14 years, 1 month ago (2011-03-28 04:02:29 UTC) #10
rog
http://codereview.appspot.com/4306056/diff/4001/src/pkg/strings/strings.go File src/pkg/strings/strings.go (right): http://codereview.appspot.com/4306056/diff/4001/src/pkg/strings/strings.go#newcode331 src/pkg/strings/strings.go:331: b = []byte(s) it would be easier to be ...
14 years, 1 month ago (2011-03-28 08:07:48 UTC) #11
eh
On 28 March 2011 09:07, <rogpeppe@gmail.com> wrote: > > http://codereview.appspot.com/4306056/diff/4001/src/pkg/strings/strings.go > File src/pkg/strings/strings.go (right): > ...
14 years, 1 month ago (2011-03-28 08:15:22 UTC) #12
rog
On 28 March 2011 09:15, chris dollin <ehog.hedge@googlemail.com> wrote: > On 28 March 2011 09:07, ...
14 years, 1 month ago (2011-03-28 08:20:22 UTC) #13
rog
On 28 March 2011 04:20, Rob 'Commander' Pike <r@golang.org> wrote: > maybe. i'm surprised, though. ...
14 years, 1 month ago (2011-03-28 10:20:50 UTC) #14
rog
On 28 March 2011 02:58, <r@golang.org> wrote: > > http://codereview.appspot.com/4306056/diff/4001/src/pkg/strings/strings.go > File src/pkg/strings/strings.go (right): > ...
14 years, 1 month ago (2011-03-28 10:28:45 UTC) #15
bradfitz
But you call the mapping function more often. Have you benchmarked a wide variety of ...
14 years, 1 month ago (2011-03-28 16:15:36 UTC) #16
bradfitz
On Sun, Mar 27, 2011 at 8:59 PM, <r@golang.org> wrote: > looks good but you ...
14 years, 1 month ago (2011-03-28 16:18:19 UTC) #17
rsc1
At the risk of bikeshedding this further, I think the CL is too complex for ...
14 years, 1 month ago (2011-03-28 16:29:05 UTC) #18
rog
On 28 March 2011 17:15, Brad Fitzpatrick <bradfitz@golang.org> wrote: > But you call the mapping ...
14 years, 1 month ago (2011-03-28 16:31:17 UTC) #19
bradfitz
Hello golang-dev@googlegroups.com, r, bradfitzwork, rog, eh, rsc1 (cc: golang-dev@googlegroups.com), I'd like you to review this ...
14 years, 1 month ago (2011-03-28 16:35:02 UTC) #20
rsc
LGTM
14 years, 1 month ago (2011-03-28 16:36:20 UTC) #21
rog
LGTM although is it really worth having maxbytes as a separate variable when we could ...
14 years, 1 month ago (2011-03-28 16:40:34 UTC) #22
bradfitz
*** Submitted as http://code.google.com/p/go/source/detail?r=65815920b95a *** strings: Map: avoid allocation when string is unchanged This speeds ...
14 years, 1 month ago (2011-03-28 16:42:14 UTC) #23
bradfitz
14 years, 1 month ago (2011-03-28 16:43:34 UTC) #24
Roger,

Feel free to continue to work on it.

I just wandered into that code on accident and need to pop back out to other
stuff.

- Brad

On Mon, Mar 28, 2011 at 9:40 AM, roger peppe <rogpeppe@gmail.com> wrote:

> LGTM
>
> although is it really worth having maxbytes as a separate
> variable when we could just use len(b) ?
>
> On 28 March 2011 17:35,  <bradfitz@golang.org> wrote:
> > Hello golang-dev@googlegroups.com, r, bradfitzwork, rog, eh, rsc1 (cc:
> > golang-dev@googlegroups.com),
> >
> > I'd like you to review this change to
> > https://go.googlecode.com/hg/
> >
> >
> > http://codereview.appspot.com/4306056/
> >
>
Sign in to reply to this message.

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