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

Unified Diff: src/js/string.js

Issue 1840723002: String.prototype.{match,search} should do only one RegExp brand check (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 9 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/js/regexp.js ('k') | test/mjsunit/es6/pattern-brand-check.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/js/string.js
diff --git a/src/js/string.js b/src/js/string.js
index 40fc099709fa5d6eb94baadf42bb20e000c91c78..498021381a5181e8420a4940ce5e0e4082301e65 100644
--- a/src/js/string.js
+++ b/src/js/string.js
@@ -20,6 +20,7 @@ var MakeRangeError;
var MakeTypeError;
var MaxSimple;
var MinSimple;
+var RegExpInitialize;
var matchSymbol = utils.ImportNow("match_symbol");
var replaceSymbol = utils.ImportNow("replace_symbol");
var searchSymbol = utils.ImportNow("search_symbol");
@@ -33,6 +34,7 @@ utils.Import(function(from) {
MakeTypeError = from.MakeTypeError;
MaxSimple = from.MaxSimple;
MinSimple = from.MinSimple;
+ RegExpInitialize = from.RegExpInitialize;
});
//-------------------------------------------------------------------
@@ -159,8 +161,9 @@ function StringMatchJS(pattern) {
var subject = TO_STRING(this);
- // Non-regexp argument.
- var regexp = new GlobalRegExp(pattern);
+ // Equivalent to RegExpCreate (ES#sec-regexpcreate)
+ var regexp = %NewObject(GlobalRegExp, GlobalRegExp);
+ RegExpInitialize(regexp, pattern);
return regexp[matchSymbol](subject);
}
@@ -355,7 +358,10 @@ function StringSearch(pattern) {
}
var subject = TO_STRING(this);
- var regexp = new GlobalRegExp(pattern);
+
+ // Equivalent to RegExpCreate (ES#sec-regexpcreate)
+ var regexp = %NewObject(GlobalRegExp, GlobalRegExp);
+ RegExpInitialize(regexp, pattern);
return %_Call(regexp[searchSymbol], regexp, subject);
}
« no previous file with comments | « src/js/regexp.js ('k') | test/mjsunit/es6/pattern-brand-check.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698