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

Issue 5959002: Improve regexp split, replace and test. (Closed)

Created:
10 years ago by sandholm
Modified:
9 years, 7 months ago
Reviewers:
Lasse Reichstein
CC:
v8-dev
Visibility:
Public.

Description

Improve regexp split, replace and test.

Patch Set 1 #

Total comments: 10

Patch Set 2 : '' #

Unified diffs Side-by-side diffs Delta from patch set Stats (+44 lines, -50 lines) Patch
M src/regexp.js View 1 5 chunks +15 lines, -12 lines 0 comments Download
M src/string.js View 1 9 chunks +29 lines, -38 lines 0 comments Download

Messages

Total messages: 3 (0 generated)
sandholm
10 years ago (2010-12-17 10:27:29 UTC) #1
Lasse Reichstein
L-sorta-GTM. Most of the changes are ugly inlining of existing functions. It shouldn't be necessary ...
10 years ago (2010-12-17 10:38:30 UTC) #2
sandholm
10 years ago (2010-12-17 11:50:24 UTC) #3
http://codereview.chromium.org/5959002/diff/1/src/regexp.js
File src/regexp.js (right):

http://codereview.chromium.org/5959002/diff/1/src/regexp.js#newcode265
src/regexp.js:265: (this.ignoreCase ? 'i' : '')
On 2010/12/17 10:38:30, Lasse Reichstein wrote:
> How about:
>   (this.ignoreCase ? this.multiline ? "im" : "i" : this.multiline ? "m" : "")
> to avoid the string-concatenation?

Done.

http://codereview.chromium.org/5959002/diff/1/src/regexp.js#newcode268
src/regexp.js:268: if (%_RegExpExec(regexp_val, string, 0, lastMatchInfo) ===
null) {
On 2010/12/17 10:38:30, Lasse Reichstein wrote:
> Use DoRegExpExec, or remember to clear lastMatchIndoOverride.

The result is only used if there was no match. Otherwise, the "actual" exec call
is made below in which case the lastMatchInfoOverride gets overridden.

http://codereview.chromium.org/5959002/diff/1/src/string.js
File src/string.js (right):

http://codereview.chromium.org/5959002/diff/1/src/string.js#newcode257
src/string.js:257: if (next > 0) builder.elements.push(SubString(string, 0,
next));
On 2010/12/17 10:38:30, Lasse Reichstein wrote:
> Consider extracting elements from builder, so you don't need the
> builder.elements redirection.
> But it's a nasty hack to access the underlying array directly. It better be
> significantly faster!

Done.

http://codereview.chromium.org/5959002/diff/1/src/string.js#newcode574
src/string.js:574: if (IS_NULL_OR_UNDEFINED(matchInfo)
On 2010/12/17 10:38:30, Lasse Reichstein wrote:
> Why accept undefined?

I am just applying the same semantics as the inlined splitMatch function. I will
change it to (matchInfo == null) which seems easier on the eyes.

http://codereview.chromium.org/5959002/diff/1/src/string.js#newcode587
src/string.js:587: if (currentIndex + 1 == startMatch) {
On 2010/12/17 10:38:30, Lasse Reichstein wrote:
> Does this really pay off? It seems to be simply inlining the definition of
> SubString, and we don't want to do that everywhere.

It is faster. I generally only inline call sites where the SubString call is in
a loop.

Powered by Google App Engine
This is Rietveld 408576698