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

Side by Side Diff: src/array.js

Issue 8353006: Fix Array.filter to use internal array for result. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 2 months 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | test/test262/test262.status » ('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 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 999 matching lines...) Expand 10 before | Expand all | Expand 10 after
1010 1010
1011 if (!IS_SPEC_FUNCTION(f)) { 1011 if (!IS_SPEC_FUNCTION(f)) {
1012 throw MakeTypeError('called_non_callable', [ f ]); 1012 throw MakeTypeError('called_non_callable', [ f ]);
1013 } 1013 }
1014 if (IS_NULL_OR_UNDEFINED(receiver)) { 1014 if (IS_NULL_OR_UNDEFINED(receiver)) {
1015 receiver = %GetDefaultReceiver(f) || receiver; 1015 receiver = %GetDefaultReceiver(f) || receiver;
1016 } else if (!IS_SPEC_OBJECT(receiver)) { 1016 } else if (!IS_SPEC_OBJECT(receiver)) {
1017 receiver = ToObject(receiver); 1017 receiver = ToObject(receiver);
1018 } 1018 }
1019 1019
1020 var result = []; 1020 var result = new $Array();
1021 var result_length = 0; 1021 var accumulator = new InternalArray();
1022 var accumulator_length = 0;
1022 for (var i = 0; i < length; i++) { 1023 for (var i = 0; i < length; i++) {
1023 var current = array[i]; 1024 var current = array[i];
1024 if (!IS_UNDEFINED(current) || i in array) { 1025 if (!IS_UNDEFINED(current) || i in array) {
1025 if (%_CallFunction(receiver, current, i, array, f)) { 1026 if (%_CallFunction(receiver, current, i, array, f)) {
1026 result[result_length++] = current; 1027 accumulator[accumulator_length++] = current;
1027 } 1028 }
1028 } 1029 }
1029 } 1030 }
1031 %MoveArrayContents(accumulator, result);
1030 return result; 1032 return result;
1031 } 1033 }
1032 1034
1033 1035
1034 function ArrayForEach(f, receiver) { 1036 function ArrayForEach(f, receiver) {
1035 if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) { 1037 if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) {
1036 throw MakeTypeError("called_on_null_or_undefined", 1038 throw MakeTypeError("called_on_null_or_undefined",
1037 ["Array.prototype.forEach"]); 1039 ["Array.prototype.forEach"]);
1038 } 1040 }
1039 1041
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
1413 // exposed to user code. 1415 // exposed to user code.
1414 // Adding only the functions that are actually used. 1416 // Adding only the functions that are actually used.
1415 SetUpLockedPrototype(InternalArray, $Array(), $Array( 1417 SetUpLockedPrototype(InternalArray, $Array(), $Array(
1416 "join", getFunction("join", ArrayJoin), 1418 "join", getFunction("join", ArrayJoin),
1417 "pop", getFunction("pop", ArrayPop), 1419 "pop", getFunction("pop", ArrayPop),
1418 "push", getFunction("push", ArrayPush) 1420 "push", getFunction("push", ArrayPush)
1419 )); 1421 ));
1420 } 1422 }
1421 1423
1422 SetUpArray(); 1424 SetUpArray();
OLDNEW
« no previous file with comments | « no previous file | test/test262/test262.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698