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

Issue 1731048: code review 1731048: bytes, strings: add Replace (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
13 years, 10 months ago by rsc
Modified:
13 years, 10 months ago
Reviewers:
CC:
r, cw, golang-dev
Visibility:
Public.

Description

bytes, strings: add Replace This is the Replace I suggested in the review of CL 1114041. It's true that we already have regexp.MustCompile(regexp.QuoteMeta(old)).ReplaceAll(s, new) but because this Replace is doing a simpler job it is simpler to call and inherently more efficient. I will add the bytes implementation and tests to the CL after the strings one has been reviewed.

Patch Set 1 #

Patch Set 2 : code review 1731048: bytes, strings: add Replace #

Total comments: 3

Patch Set 3 : code review 1731048: bytes, strings: add Replace #

Patch Set 4 : code review 1731048: bytes, strings: add Replace #

Patch Set 5 : code review 1731048: bytes, strings: add Replace #

Patch Set 6 : code review 1731048: bytes, strings: add Replace #

Unified diffs Side-by-side diffs Delta from patch set Stats (+153 lines, -0 lines) Patch
M src/pkg/bytes/bytes.go View 1 chunk +33 lines, -0 lines 0 comments Download
M src/pkg/bytes/bytes_test.go View 5 1 chunk +36 lines, -0 lines 0 comments Download
M src/pkg/strings/strings.go View 1 2 3 1 chunk +48 lines, -0 lines 0 comments Download
M src/pkg/strings/strings_test.go View 1 2 3 4 5 1 chunk +36 lines, -0 lines 0 comments Download

Messages

Total messages: 14
rsc
Hello r, cw (cc: golang-dev@googlegroups.com), I'd like you to review this change.
13 years, 10 months ago (2010-06-30 21:41:15 UTC) #1
r
http://codereview.appspot.com/1731048/diff/2001/3001 File src/pkg/strings/strings.go (right): http://codereview.appspot.com/1731048/diff/2001/3001#newcode467 src/pkg/strings/strings.go:467: if old == new { is this necessary? it's ...
13 years, 10 months ago (2010-06-30 21:55:19 UTC) #2
rsc
> is this necessary? it's a rare case. worth checking? i think the code > ...
13 years, 10 months ago (2010-06-30 22:22:27 UTC) #3
rsc
Hello r, cw (cc: golang-dev@googlegroups.com), Please take another look.
13 years, 10 months ago (2010-06-30 22:22:39 UTC) #4
r2
LGTM On Jun 30, 2010, at 3:22 PM, Russ Cox wrote: >> is this necessary? ...
13 years, 10 months ago (2010-06-30 22:29:29 UTC) #5
cw
I always wondered why we don't have a bytes version of these functions then use ...
13 years, 10 months ago (2010-06-30 22:35:56 UTC) #6
rsc
On Wed, Jun 30, 2010 at 15:35, <cw@f00f.org> wrote: > I always wondered why we ...
13 years, 10 months ago (2010-06-30 23:36:42 UTC) #7
cw
On Wed, Jun 30, 2010 at 04:36:36PM -0700, Russ Cox wrote: > It's to avoid ...
13 years, 10 months ago (2010-07-01 00:10:36 UTC) #8
rsc
> so why not copy once to []byte and use unsafe to create a string ...
13 years, 10 months ago (2010-07-01 00:20:12 UTC) #9
rsc
Please take another look. Added bytes routines to CL.
13 years, 10 months ago (2010-07-01 00:41:42 UTC) #10
r
LGTM my only concern is whether n==0 should mean forever, or only n < 0. ...
13 years, 10 months ago (2010-07-01 00:45:20 UTC) #11
rsc
On Wed, Jun 30, 2010 at 17:45, <r@golang.org> wrote: > LGTM > > my only ...
13 years, 10 months ago (2010-07-01 00:48:56 UTC) #12
r2
On Jun 30, 2010, at 5:48 PM, Russ Cox wrote: > On Wed, Jun 30, ...
13 years, 10 months ago (2010-07-01 00:50:26 UTC) #13
rsc
13 years, 10 months ago (2010-07-01 01:03:13 UTC) #14
*** Submitted as http://code.google.com/p/go/source/detail?r=6470c731be0e ***

bytes, strings: add Replace

This is the Replace I suggested in the review of CL 1114041.
It's true that we already have

	regexp.MustCompile(regexp.QuoteMeta(old)).ReplaceAll(s, new)

but because this Replace is doing a simpler job it is
simpler to call and inherently more efficient.

I will add the bytes implementation and tests to the
CL after the strings one has been reviewed.

R=r, cw
CC=golang-dev
http://codereview.appspot.com/1731048
Sign in to reply to this message.

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