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

Unified Diff: src/string.js

Issue 875001: Converted String.prototype.split with string to C++. (Closed)
Patch Set: Rewrote conditions to switch with fallthrough. Created 10 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
« src/runtime.cc ('K') | « src/runtime.cc ('k') | 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 e22c93b90391e12e12fcdd9f5462124ed18b7a67..2fe17f8e5ed814680f00f2d79df55a5cccc9a686 100644
--- a/src/string.js
+++ b/src/string.js
@@ -557,7 +557,7 @@ function StringSplit(separator, limit) {
// ECMA-262 says that if separator is undefined, the result should
// be an array of size 1 containing the entire string. SpiderMonkey
- // and KJS have this behaviour only when no separator is given. If
+ // and KJS have this behavior only when no separator is given. If
Erik Corry 2010/03/15 12:57:48 !@*%$
// undefined is explicitly given, they convert it to a string and
// use that. We do as SpiderMonkey and KJS.
if (%_ArgumentsLength() === 0) {
@@ -572,18 +572,7 @@ function StringSplit(separator, limit) {
// If the separator string is empty then return the elements in the subject.
if (separator_length === 0) return %StringToArray(subject);
- var result = [];
- var start_index = 0;
- var index;
- while (true) {
- if (start_index + separator_length > length ||
- (index = %StringIndexOf(subject, separator, start_index)) === -1) {
- result.push(SubString(subject, start_index, length));
- break;
- }
- if (result.push(SubString(subject, start_index, index)) === limit) break;
- start_index = index + separator_length;
- }
+ var result = %StringSplit(subject, separator, limit);
return result;
}
« src/runtime.cc ('K') | « src/runtime.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698