Reviewers: Jakob,

Message:
PTAL.

Description:
Split up String.split to deal with normal separator and regexp separator
separately.


BUG=
TEST=


Please review this at http://codereview.chromium.org/9694041/

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files:
  M src/string.js


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) {


--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to