OLD | NEW |
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 143 matching lines...) Loading... |
154 if (IS_NUMBER(e)) elements[i] = %_NumberToString(e); | 154 if (IS_NUMBER(e)) elements[i] = %_NumberToString(e); |
155 else { | 155 else { |
156 if (!IS_STRING(e)) e = convert(e); | 156 if (!IS_STRING(e)) e = convert(e); |
157 elements[i] = e; | 157 elements[i] = e; |
158 } | 158 } |
159 } | 159 } |
160 } | 160 } |
161 var result = %_FastAsciiArrayJoin(elements, separator); | 161 var result = %_FastAsciiArrayJoin(elements, separator); |
162 if (!IS_UNDEFINED(result)) return result; | 162 if (!IS_UNDEFINED(result)) return result; |
163 | 163 |
164 var length2 = (length << 1) - 1; | 164 return %StringBuilderJoin(elements, length, separator); |
165 var j = length2; | |
166 var i = length; | |
167 elements[--j] = elements[--i]; | |
168 while (i > 0) { | |
169 elements[--j] = separator; | |
170 elements[--j] = elements[--i]; | |
171 } | |
172 return %StringBuilderConcat(elements, length2, ''); | |
173 } finally { | 165 } finally { |
174 // Make sure to remove the last element of the visited array no | 166 // Make sure to remove the last element of the visited array no |
175 // matter what happens. | 167 // matter what happens. |
176 if (is_array) visited_arrays.length = visited_arrays.length - 1; | 168 if (is_array) visited_arrays.length = visited_arrays.length - 1; |
177 } | 169 } |
178 } | 170 } |
179 | 171 |
180 | 172 |
181 function ConvertToString(x) { | 173 function ConvertToString(x) { |
182 // Assumes x is a non-string. | 174 // Assumes x is a non-string. |
(...skipping 1048 matching lines...) Loading... |
1231 "lastIndexOf", getFunction("lastIndexOf", ArrayLastIndexOf, 1), | 1223 "lastIndexOf", getFunction("lastIndexOf", ArrayLastIndexOf, 1), |
1232 "reduce", getFunction("reduce", ArrayReduce, 1), | 1224 "reduce", getFunction("reduce", ArrayReduce, 1), |
1233 "reduceRight", getFunction("reduceRight", ArrayReduceRight, 1) | 1225 "reduceRight", getFunction("reduceRight", ArrayReduceRight, 1) |
1234 )); | 1226 )); |
1235 | 1227 |
1236 %FinishArrayPrototypeSetup($Array.prototype); | 1228 %FinishArrayPrototypeSetup($Array.prototype); |
1237 } | 1229 } |
1238 | 1230 |
1239 | 1231 |
1240 SetupArray(); | 1232 SetupArray(); |
OLD | NEW |