Chromium Code Reviews| Index: src/string.js |
| diff --git a/src/string.js b/src/string.js |
| index e663ec304432f00b71c88765ac4858597e029156..1c72f3bc478d9a04ea3aa2f274efce5c0a2dfa01 100644 |
| --- a/src/string.js |
| +++ b/src/string.js |
| @@ -521,9 +521,16 @@ function ApplyReplacementFunction(replace, matchInfo, subject) { |
| } |
| +var re_cache = {} |
| + |
| + |
| // ECMA-262 section 15.5.4.12 |
| function StringSearch(re) { |
| - var regexp = new $RegExp(re); |
| + var regexp = re_cache[re]; |
| + if (IS_UNDEFINED(regexp)) { |
|
sandholm
2010/03/25 05:36:24
Maybe reset cache at size 10, 100 or 1000 to avoid
|
| + regexp = new $RegExp(re); |
| + re_cache[re] = regexp; |
| + } |
| var s = TO_STRING_INLINE(this); |
| var last_idx = regexp.lastIndex; // keep old lastIndex |
|
Lasse Reichstein
2010/03/25 08:05:13
Use:
var match = DoRegExpExec(regexp, s, 0);
i
Lasse Reichstein
2010/03/25 08:53:11
I'll just make a changelist for this on its own.
|
| regexp.lastIndex = 0; // ignore re.global property |