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

Unified Diff: src/string.js

Issue 1563005: Introduce fast native caches and use it in String.search. (Closed)
Patch Set: Last round :) Created 10 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/runtime.cc ('k') | src/x64/codegen-x64.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/string.js
diff --git a/src/string.js b/src/string.js
index 7ddc467fc0de2421c21fd39e36456a438dcb30e3..0736b4b0fe1324416510f474015db2d718d6ecdb 100644
--- a/src/string.js
+++ b/src/string.js
@@ -529,10 +529,16 @@ function ApplyReplacementFunction(replace, matchInfo, subject) {
return replace.apply(null, parameters);
}
-
// ECMA-262 section 15.5.4.12
function StringSearch(re) {
- var regexp = new $RegExp(re);
+ var regexp;
+ if (IS_STRING(re)) {
+ regexp = %_GetFromCache(STRING_TO_REGEXP_CACHE_ID, re);
+ } else if (IS_REGEXP(re)) {
+ regexp = re;
+ } else {
+ regexp = new $RegExp(re);
+ }
var s = TO_STRING_INLINE(this);
var match = DoRegExpExec(regexp, s, 0);
if (match) {
« no previous file with comments | « src/runtime.cc ('k') | src/x64/codegen-x64.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698