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

Unified Diff: src/string.js

Issue 9694041: Split up String.split to deal with normal separator and regexp separator separately. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 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 | « no previous file | no next file » | 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 3caaff43df91563faac196fd2d1a83bdb6fd200d..5fcd1e7eab17a06b5b9d815af48ca66e3407b7e0 100644
--- a/src/string.js
+++ b/src/string.js
@@ -592,12 +592,12 @@ function StringSplit(separator, limit) {
return [subject];
}
+ if (limit === 0) return [];
+
var length = subject.length;
if (!IS_REGEXP(separator)) {
separator = TO_STRING_INLINE(separator);
- if (limit === 0) return [];
-
var separator_length = separator.length;
// If the separator string is empty then return the elements in the subject.
@@ -608,8 +608,12 @@ function StringSplit(separator, limit) {
return result;
}
- if (limit === 0) return [];
+ // Separator is a regular expression.
+ return StringSplitOnRegExp(subject, separator, limit, length);
+}
+
+function StringSplitOnRegExp(subject, separator, limit, length) {
%_Log('regexp', 'regexp-split,%0S,%1r', [subject, separator]);
if (length === 0) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698