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

Unified Diff: src/string.js

Issue 119093002: Fix small spec violation in String.prototype.split. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years 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/mjsunit/regress/regress-3026.js » ('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 14b44ca41f3d7f248a5756b54983f09ab3a55c8e..dd5115d5bf311cb2bc827b33c240b381f480b004 100644
--- a/src/string.js
+++ b/src/string.js
@@ -616,24 +616,22 @@ function StringSplit(separator, limit) {
var subject = TO_STRING_INLINE(this);
limit = (IS_UNDEFINED(limit)) ? 0xffffffff : TO_UINT32(limit);
- // ECMA-262 says that if separator is undefined, the result should
- // be an array of size 1 containing the entire string.
- if (IS_UNDEFINED(separator)) {
- return [subject];
- }
-
var length = subject.length;
if (!IS_REGEXP(separator)) {
- separator = TO_STRING_INLINE(separator);
+ var separator_string = TO_STRING_INLINE(separator);
if (limit === 0) return [];
- var separator_length = separator.length;
+ // ECMA-262 says that if separator is undefined, the result should
+ // be an array of size 1 containing the entire string.
+ if (IS_UNDEFINED(separator)) return [subject];
+
+ var separator_length = separator_string.length;
// If the separator string is empty then return the elements in the subject.
if (separator_length === 0) return %StringToArray(subject, limit);
- var result = %StringSplit(subject, separator, limit);
+ var result = %StringSplit(subject, separator_string, limit);
return result;
}
« no previous file with comments | « no previous file | test/mjsunit/regress/regress-3026.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698