| OLD | NEW |
| 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 512 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 523 if (%_ArgumentsLength() === 0) { | 523 if (%_ArgumentsLength() === 0) { |
| 524 return [subject]; | 524 return [subject]; |
| 525 } | 525 } |
| 526 | 526 |
| 527 var length = subject.length; | 527 var length = subject.length; |
| 528 if (!IS_REGEXP(separator)) { | 528 if (!IS_REGEXP(separator)) { |
| 529 separator = TO_STRING_INLINE(separator); | 529 separator = TO_STRING_INLINE(separator); |
| 530 var separator_length = separator.length; | 530 var separator_length = separator.length; |
| 531 | 531 |
| 532 // If the separator string is empty then return the elements in the subject. | 532 // If the separator string is empty then return the elements in the subject. |
| 533 if (separator_length === 0) { | 533 if (separator_length === 0) return %StringToArray(subject); |
| 534 var result = $Array(length); | |
| 535 for (var i = 0; i < length; i++) result[i] = subject[i]; | |
| 536 return result; | |
| 537 } | |
| 538 | 534 |
| 539 var result = []; | 535 var result = []; |
| 540 var start_index = 0; | 536 var start_index = 0; |
| 541 var index; | 537 var index; |
| 542 while (true) { | 538 while (true) { |
| 543 if (start_index + separator_length > length || | 539 if (start_index + separator_length > length || |
| 544 (index = %StringIndexOf(subject, separator, start_index)) === -1) { | 540 (index = %StringIndexOf(subject, separator, start_index)) === -1) { |
| 545 result.push(SubString(subject, start_index, length)); | 541 result.push(SubString(subject, start_index, length)); |
| 546 break; | 542 break; |
| 547 } | 543 } |
| (...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 904 "small", StringSmall, | 900 "small", StringSmall, |
| 905 "strike", StringStrike, | 901 "strike", StringStrike, |
| 906 "sub", StringSub, | 902 "sub", StringSub, |
| 907 "sup", StringSup, | 903 "sup", StringSup, |
| 908 "toJSON", StringToJSON | 904 "toJSON", StringToJSON |
| 909 )); | 905 )); |
| 910 } | 906 } |
| 911 | 907 |
| 912 | 908 |
| 913 SetupString(); | 909 SetupString(); |
| OLD | NEW |