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

Unified Diff: src/js/i18n.js

Issue 2126073002: Avoid calling the builtin String.prototype.split in Intl (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 5 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 | « no previous file | test/intl/regress-5179.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/js/i18n.js
diff --git a/src/js/i18n.js b/src/js/i18n.js
index dd85a0526495c926bc55ba011769dca720059d3c..e018262ca2b76fedce02c82fc6d8ce9866e8b747 100644
--- a/src/js/i18n.js
+++ b/src/js/i18n.js
@@ -41,7 +41,6 @@ var resolvedSymbol = utils.ImportNow("intl_resolved_symbol");
var SetFunctionName = utils.SetFunctionName;
var StringIndexOf;
var StringLastIndexOf;
-var StringSplit;
var StringSubstr;
var StringSubstring;
@@ -57,7 +56,6 @@ utils.Import(function(from) {
InternalRegExpReplace = from.InternalRegExpReplace;
StringIndexOf = from.StringIndexOf;
StringLastIndexOf = from.StringLastIndexOf;
- StringSplit = from.StringSplit;
StringSubstr = from.StringSubstr;
StringSubstring = from.StringSubstring;
});
@@ -125,6 +123,15 @@ function AddBoundMethod(obj, methodName, implementation, length, type) {
%SetNativeFlag(getter);
}
+// Special StringSplit function for this file; does not work with RegExps
+// or access Symbol.split, but per spec, is just for strings.
+function StringSplit(separator, limit) {
+ var subject = TO_STRING(this);
+ var separator_string = TO_STRING(separator);
+ limit = (IS_UNDEFINED(limit)) ? kMaxUint32 : TO_UINT32(limit);
Yang 2016/07/07 09:13:01 I don't think StringSplit is used with the optiona
Dan Ehrenberg 2016/07/07 18:35:42 That's true; I don't see a real need to call TO_ST
+ return %StringSplit(this, separator, limit);
+}
+
// -------------------------------------------------------------------
var Intl = {};
« no previous file with comments | « no previous file | test/intl/regress-5179.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698