Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(293)

Issue 1994019: Simplified replace JS a little. (Closed)

Created:
10 years, 7 months ago by Lasse Reichstein
Modified:
9 years, 6 months ago
Reviewers:
Erik Corry, antonm, Rico
CC:
v8-dev
Visibility:
Public.

Description

Simplified replace JS. Refactored code so global/non-global regexps are handled in separate functions. Inlined ApplyReplaceFunction at its only call point.

Patch Set 1 #

Total comments: 3

Patch Set 2 : Larger refactoring of replace code. #

Total comments: 9

Patch Set 3 : Address review comments. Forward to head. #

Unified diffs Side-by-side diffs Delta from patch set Stats (+101 lines, -92 lines) Patch
M src/string.js View 1 2 4 chunks +101 lines, -92 lines 0 comments Download

Messages

Total messages: 6 (0 generated)
Lasse Reichstein
Small JS-change.
10 years, 7 months ago (2010-05-12 14:26:14 UTC) #1
Lasse Reichstein
http://codereview.chromium.org/1994019/diff/1/2 File src/string.js (right): http://codereview.chromium.org/1994019/diff/1/2#newcode399 src/string.js:399: // If start isn't valid, return undefined. lastCaptureInfo holds ...
10 years, 7 months ago (2010-05-12 14:29:48 UTC) #2
Lasse Reichstein
http://codereview.chromium.org/1994019/diff/1/2 File src/string.js (right): http://codereview.chromium.org/1994019/diff/1/2#newcode522 src/string.js:522: return %_CallFunction(global, s, index, subject, replace); Is "global" the ...
10 years, 7 months ago (2010-05-12 14:31:40 UTC) #3
antonm
drive-by http://codereview.chromium.org/1994019/diff/1/2 File src/string.js (right): http://codereview.chromium.org/1994019/diff/1/2#newcode522 src/string.js:522: return %_CallFunction(global, s, index, subject, replace); On 2010/05/12 ...
10 years, 7 months ago (2010-05-12 14:35:05 UTC) #4
antonm
LGTM http://codereview.chromium.org/1994019/diff/7001/8001 File src/string.js (right): http://codereview.chromium.org/1994019/diff/7001/8001#newcode406 src/string.js:406: if (start < 0) return; you omit end ...
10 years, 7 months ago (2010-05-13 11:43:17 UTC) #5
Lasse Reichstein
10 years, 7 months ago (2010-05-13 12:13:11 UTC) #6
http://codereview.chromium.org/1994019/diff/7001/8001
File src/string.js (right):

http://codereview.chromium.org/1994019/diff/7001/8001#newcode406
src/string.js:406: if (start < 0) return;
It should be fine. If lastCaptureInfo was created by us (in the RegExp engine),
then (start < 0) iff (end < 0).
If someone malicious has changed lastCaptureInfo, then we will just get invalid
values for SubString, which tests its arguments, and, at most, returns a
different substring.

http://codereview.chromium.org/1994019/diff/7001/8001#newcode449
src/string.js:449: return subject;
It could and probably should. 
(There used to be a try-finally around it, and I can see I was a little careless
when I removed it).

http://codereview.chromium.org/1994019/diff/7001/8001#newcode470
src/string.js:470: %_CallFunction(receiver, elem, match_start, subject,
replace);
I don't think we have a debug assert (Something like %_Assert(expr,str)) would
be a logical idea). In this case, we only know it's a function because this
function is only called if replace is a function (hence its name
"...WithFunction").

http://codereview.chromium.org/1994019/diff/7001/8001#newcode517
src/string.js:517: var s = SubString(subject, index, matchInfo[CAPTURE1]);
Good catch.

Powered by Google App Engine
This is Rietveld 408576698