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

Issue 2645002: Simplify regexp test call when the regexp starts and ends with '.*'. (Closed)

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

Description

Simplify regexp test call when the regexp starts and ends with '.*'. Committed: http://code.google.com/p/v8/source/detail?r=4799

Patch Set 1 #

Patch Set 2 : '' #

Total comments: 6
Unified diffs Side-by-side diffs Delta from patch set Stats (+25 lines, -3 lines) Patch
M src/regexp.js View 1 4 chunks +25 lines, -3 lines 6 comments Download

Messages

Total messages: 3 (0 generated)
sandholm
10 years, 6 months ago (2010-06-04 11:19:16 UTC) #1
Lasse Reichstein
LGTM http://codereview.chromium.org/2645002/diff/2001/3001 File src/regexp.js (right): http://codereview.chromium.org/2645002/diff/2001/3001#newcode262 src/regexp.js:262: var regexp_val; How often do you hit this? ...
10 years, 6 months ago (2010-06-04 11:30:33 UTC) #2
sandholm
10 years, 6 months ago (2010-06-04 11:57:23 UTC) #3
http://codereview.chromium.org/2645002/diff/2001/3001
File src/regexp.js (right):

http://codereview.chromium.org/2645002/diff/2001/3001#newcode262
src/regexp.js:262: var regexp_val;
On 2010/06/04 11:30:33, Lasse Reichstein wrote:
> How often do you hit this? (And how often will you hit it if you cache
negative
> results in the global regexp cache)?
Caching negative results in the global regexp cache won't change the hit rate
for this cache as test is often called with a new string.

http://codereview.chromium.org/2645002/diff/2001/3001#newcode299
src/regexp.js:299: if (%_StringCharCodeAt(this.source,0) == 46 && // '.'
On 2010/06/04 11:30:33, Lasse Reichstein wrote:
> You may want to try moving this.source to a local variable. It is used a lot.
> Ditto for this.source.length.
Tried this. Causes regressions on some benchmarks

http://codereview.chromium.org/2645002/diff/2001/3001#newcode313
src/regexp.js:313: if (!regexp_val.test(s)) return false;
On 2010/06/04 11:30:33, Lasse Reichstein wrote:
> You can cache the negative result in the regexp cache here (using the original
> regexp as key). That means that next time you call test, the global regexp
cache
> will match and you don't even get here.
Often test is called with a new string so that won't really pay off in the end.

Powered by Google App Engine
This is Rietveld 408576698