Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 81 } | 81 } |
| 82 var subject = ToString(this); | 82 var subject = ToString(this); |
| 83 var index = TO_INTEGER(pos); | 83 var index = TO_INTEGER(pos); |
| 84 return %StringCharCodeAt(subject, index); | 84 return %StringCharCodeAt(subject, index); |
| 85 } | 85 } |
| 86 | 86 |
| 87 | 87 |
| 88 // ECMA-262, section 15.5.4.6 | 88 // ECMA-262, section 15.5.4.6 |
| 89 function StringConcat() { | 89 function StringConcat() { |
| 90 var len = %_ArgumentsLength(); | 90 var len = %_ArgumentsLength(); |
| 91 var parts = new $Array(len + 1); | 91 var this_string = ToString(this); |
|
Christian Plesner Hansen
2009/10/02 05:47:12
I would suggest using %StringAdd if len == 1 and u
| |
| 92 parts[0] = ToString(this); | 92 for (var i = 0; i < len; i++) { |
| 93 for (var i = 0; i < len; i++) | 93 this_string = %StringAdd(this_string, ToString(%_Arguments(i))); |
| 94 parts[i + 1] = ToString(%_Arguments(i)); | 94 } |
| 95 return parts.join(''); | 95 return this_string; |
| 96 } | 96 } |
| 97 | 97 |
| 98 // Match ES3 and Safari | 98 // Match ES3 and Safari |
| 99 %FunctionSetLength(StringConcat, 1); | 99 %FunctionSetLength(StringConcat, 1); |
| 100 | 100 |
| 101 | 101 |
| 102 // ECMA-262 section 15.5.4.7 | 102 // ECMA-262 section 15.5.4.7 |
| 103 function StringIndexOf(searchString /* position */) { // length == 1 | 103 function StringIndexOf(searchString /* position */) { // length == 1 |
| 104 var subject_str = ToString(this); | 104 var subject_str = ToString(this); |
| 105 var pattern_str = ToString(searchString); | 105 var pattern_str = ToString(searchString); |
| (...skipping 761 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 867 "small", StringSmall, | 867 "small", StringSmall, |
| 868 "strike", StringStrike, | 868 "strike", StringStrike, |
| 869 "sub", StringSub, | 869 "sub", StringSub, |
| 870 "sup", StringSup, | 870 "sup", StringSup, |
| 871 "toJSON", StringToJSON | 871 "toJSON", StringToJSON |
| 872 )); | 872 )); |
| 873 } | 873 } |
| 874 | 874 |
| 875 | 875 |
| 876 SetupString(); | 876 SetupString(); |
| OLD | NEW |