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

Side by Side Diff: src/string.js

Issue 4750003: Make String.prototype.split honor limit when separator is empty. (Closed)
Patch Set: Created 10 years, 1 month 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 unified diff | Download patch
« no previous file with comments | « src/runtime.cc ('k') | test/mjsunit/string-split.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2009 the V8 project authors. All rights reserved. 1 // Copyright 2006-2009 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 if (%_ArgumentsLength() === 0) { 545 if (%_ArgumentsLength() === 0) {
546 return [subject]; 546 return [subject];
547 } 547 }
548 548
549 var length = subject.length; 549 var length = subject.length;
550 if (!IS_REGEXP(separator)) { 550 if (!IS_REGEXP(separator)) {
551 separator = TO_STRING_INLINE(separator); 551 separator = TO_STRING_INLINE(separator);
552 var separator_length = separator.length; 552 var separator_length = separator.length;
553 553
554 // If the separator string is empty then return the elements in the subject. 554 // If the separator string is empty then return the elements in the subject.
555 if (separator_length === 0) return %StringToArray(subject); 555 if (separator_length === 0) return %StringToArray(subject, limit);
Mads Ager (chromium) 2010/11/10 09:45:32 Accidental indentation change?
556 556
557 var result = %StringSplit(subject, separator, limit); 557 var result = %StringSplit(subject, separator, limit);
558 558
559 return result; 559 return result;
560 } 560 }
561 561
562 %_Log('regexp', 'regexp-split,%0S,%1r', [subject, separator]); 562 %_Log('regexp', 'regexp-split,%0S,%1r', [subject, separator]);
563 563
564 if (length === 0) { 564 if (length === 0) {
565 if (DoRegExpExec(separator, subject, 0, 0) != null) { 565 if (DoRegExpExec(separator, subject, 0, 0) != null) {
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
929 "small", StringSmall, 929 "small", StringSmall,
930 "strike", StringStrike, 930 "strike", StringStrike,
931 "sub", StringSub, 931 "sub", StringSub,
932 "sup", StringSup, 932 "sup", StringSup,
933 "toJSON", StringToJSON 933 "toJSON", StringToJSON
934 )); 934 ));
935 } 935 }
936 936
937 937
938 SetupString(); 938 SetupString();
OLDNEW
« no previous file with comments | « src/runtime.cc ('k') | test/mjsunit/string-split.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698