Chromium Code Reviews

Side by Side Diff: src/array.js

Issue 6520004: Introduce new runtime function to make join with lower memory usage. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Removing unnecessary file Created 9 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | | Annotate | Revision Log
« no previous file with comments | « no previous file | src/runtime.h » ('j') | src/runtime.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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...)
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...)
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();
OLDNEW
« no previous file with comments | « no previous file | src/runtime.h » ('j') | src/runtime.cc » ('J')

Powered by Google App Engine