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

Issue 5081042: code review 5081042: strings: add Replacer, NewReplacer (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
12 years, 7 months ago by bradfitz
Modified:
9 years, 2 months ago
Reviewers:
rsc, bjorn.erik.pedersen
CC:
r, rsc, rog, golang-dev
Visibility:
Public.

Description

strings: add Replacer, NewReplacer This is just a new API to do many replacements at once. While the point of this API is to be faster than doing replacements one at a time, the implementation in this CL has the optimizations removed and may actually be slower. Future CLs will bring back & add optimizations.

Patch Set 1 #

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

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

Total comments: 4

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

Total comments: 10

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

Unified diffs Side-by-side diffs Delta from patch set Stats (+160 lines, -0 lines) Patch
M src/pkg/strings/Makefile View 1 1 chunk +1 line, -0 lines 0 comments Download
A src/pkg/strings/replace.go View 1 2 3 4 1 chunk +84 lines, -0 lines 0 comments Download
A src/pkg/strings/replace_test.go View 1 2 3 1 chunk +75 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
12 years, 7 months ago (2011-09-19 23:38:50 UTC) #1
r
there's a lot of stuff here, and it needs to be done for bytes as ...
12 years, 7 months ago (2011-09-19 23:49:43 UTC) #2
bradfitz
On Mon, Sep 19, 2011 at 4:49 PM, <r@golang.org> wrote: > there's a lot of ...
12 years, 7 months ago (2011-09-19 23:56:49 UTC) #3
r
the map only needs to exist in one place. strings can have a map that ...
12 years, 7 months ago (2011-09-20 00:01:32 UTC) #4
bradfitz
On Mon, Sep 19, 2011 at 5:01 PM, Rob 'Commander' Pike <r@golang.org> wrote: > the ...
12 years, 7 months ago (2011-09-20 00:06:35 UTC) #5
rsc
This is more complex than using strings.Replace and yet still not the fastest possible way ...
12 years, 7 months ago (2011-09-20 14:27:35 UTC) #6
bradfitz
I like that API proposal. I should've flagged my CL as "for discussion". In any ...
12 years, 7 months ago (2011-09-20 14:50:48 UTC) #7
r
interesting. russ came up with the same API i was about to suggest. it loses ...
12 years, 7 months ago (2011-09-20 14:52:20 UTC) #8
rsc
On Tue, Sep 20, 2011 at 10:50, Brad Fitzpatrick <bradfitz@golang.org> wrote: > How should RewriteBytes ...
12 years, 7 months ago (2011-09-20 14:54:18 UTC) #9
bradfitz
On Tue, Sep 20, 2011 at 7:52 AM, Rob 'Commander' Pike <r@golang.org> wrote: > interesting. ...
12 years, 7 months ago (2011-09-20 14:55:05 UTC) #10
rog
On 20 September 2011 15:27, Russ Cox <rsc@golang.org> wrote: > func NewReplacer(args ...string) *Replacer > ...
12 years, 7 months ago (2011-09-20 14:56:42 UTC) #11
bradfitz
On Tue, Sep 20, 2011 at 7:53 AM, Russ Cox <rsc@golang.org> wrote: > On Tue, ...
12 years, 7 months ago (2011-09-20 14:56:57 UTC) #12
r
you're right. i'm lacking my first coffee. i was thinking of just making Replace be ...
12 years, 7 months ago (2011-09-20 14:58:13 UTC) #13
rsc
On Tue, Sep 20, 2011 at 10:56, roger peppe <rogpeppe@gmail.com> wrote: > would this be ...
12 years, 7 months ago (2011-09-20 15:19:01 UTC) #14
rog
i was looking at ReplaceBytes, WriteBytes, etc which are more byte oriented. the WriteBytes and ...
12 years, 7 months ago (2011-09-20 15:57:22 UTC) #15
rsc
On Tue, Sep 20, 2011 at 11:57, roger peppe <rogpeppe@gmail.com> wrote: > the WriteBytes and ...
12 years, 7 months ago (2011-09-20 16:24:18 UTC) #16
rog
On 20 September 2011 17:24, Russ Cox <rsc@golang.org> wrote: > On Tue, Sep 20, 2011 ...
12 years, 7 months ago (2011-09-20 16:29:04 UTC) #17
bradfitz
Hello golang-dev@googlegroups.com, r@golang.org, rsc@golang.org, rogpeppe@gmail.com (cc: golang-dev@googlegroups.com), Please take another look.
12 years, 7 months ago (2011-09-20 21:29:09 UTC) #18
rsc
http://codereview.appspot.com/5081042/diff/5003/src/pkg/http/cookie.go File src/pkg/http/cookie.go (right): http://codereview.appspot.com/5081042/diff/5003/src/pkg/http/cookie.go#newcode210 src/pkg/http/cookie.go:210: var nameReplacer = strings.NewReplacer("\n", "-", "\r", "-") I still ...
12 years, 7 months ago (2011-09-20 21:30:50 UTC) #19
bradfitz
http://codereview.appspot.com/5081042/diff/5003/src/pkg/http/cookie.go File src/pkg/http/cookie.go (right): http://codereview.appspot.com/5081042/diff/5003/src/pkg/http/cookie.go#newcode210 src/pkg/http/cookie.go:210: var nameReplacer = strings.NewReplacer("\n", "-", "\r", "-") On 2011/09/20 ...
12 years, 7 months ago (2011-09-20 21:49:40 UTC) #20
bradfitz
ping On Tue, Sep 20, 2011 at 2:49 PM, <bradfitz@golang.org> wrote: > > http://codereview.appspot.com/**5081042/diff/5003/src/pkg/**http/cookie.go<http://codereview.appspot.com/5081042/diff/5003/src/pkg/http/cookie.go> > ...
12 years, 6 months ago (2011-09-28 15:42:49 UTC) #21
rsc
LGTM Please revert the uses for now, until it's fast. http://codereview.appspot.com/5081042/diff/5003/src/pkg/strings/replace.go File src/pkg/strings/replace.go (right): http://codereview.appspot.com/5081042/diff/5003/src/pkg/strings/replace.go#newcode28 ...
12 years, 6 months ago (2011-09-28 16:17:59 UTC) #22
bradfitz
*** Submitted as http://code.google.com/p/go/source/detail?r=9a44dedca5dd *** strings: add Replacer, NewReplacer This is just a new API ...
12 years, 6 months ago (2011-09-28 16:34:31 UTC) #23
bjorn.erik.pedersen_gmail.com
9 years, 2 months ago (2015-02-10 20:20:43 UTC) #24
This is old - but the most relevant thread I could find:

Any plans for a bytes.Replacer?

(the strings.Replacer is screaming fast, and it would be really nice to 
have that speed in the bytes department too).

Bjørn Erik Pedersen

tirsdag 20. september 2011 01.38.50 UTC+2 skrev Brad Fitzpatrick følgende:
>
> Reviewers: golang-dev_googlegroups.com,
>
> Message:
> Hello golan...@googlegroups.com <javascript:> (cc: 
> golan...@googlegroups.com <javascript:>),
>
> I'd like you to review this change to
> https://go.googlecode.com/hg
>
>
> Description:
> strings: add ReplacementMap
>
> Faster way to apply multiple replacements against a string at
> once, minimizing copies.  With an optimized case for when all
> the replacement source strings are single bytes.
>
> strings_test.BenchmarkOldHTTPHTMLReplace    1000000   2918 ns/op
> strings_test.BenchmarkReplaceMapSingleByte  1000000   1330 ns/op
> strings_test.BenchmarkReplaceMap             500000   5240 ns/op
>
> Please review this at http://codereview.appspot.com/5081042/
>
> Affected files:
>    M src/pkg/http/cookie.go
>    M src/pkg/http/header.go
>    M src/pkg/http/server.go
>    M src/pkg/mime/multipart/writer.go
>    M src/pkg/strings/Makefile
>    A src/pkg/strings/replace.go
>    A src/pkg/strings/replace_test.go
>
>
>
Sign in to reply to this message.

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