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

Side by Side Diff: src/array-iterator.js

Issue 21180008: Update Array Iterator to use numeric indexes (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 4 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/mjsunit/harmony/array-iterator.js » ('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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 var itemKind = iterator[arrayIterationKindSymbol]; 70 var itemKind = iterator[arrayIterationKindSymbol];
71 var length = TO_UINT32(array.length); 71 var length = TO_UINT32(array.length);
72 72
73 // "sparse" is never used. 73 // "sparse" is never used.
74 74
75 if (index >= length) { 75 if (index >= length) {
76 iterator[arrayIteratorNextIndexSymbol] = 1 / 0; // Infinity 76 iterator[arrayIteratorNextIndexSymbol] = 1 / 0; // Infinity
77 return CreateIteratorResultObject(void 0, true); 77 return CreateIteratorResultObject(void 0, true);
78 } 78 }
79 79
80 var elementKey = ToString(index);
81 iterator[arrayIteratorNextIndexSymbol] = index + 1; 80 iterator[arrayIteratorNextIndexSymbol] = index + 1;
82 81
83 if (itemKind == ARRAY_ITERATOR_KIND_VALUES) 82 if (itemKind == ARRAY_ITERATOR_KIND_VALUES)
84 return CreateIteratorResultObject(array[elementKey], false); 83 return CreateIteratorResultObject(array[index], false);
85 84
86 if (itemKind == ARRAY_ITERATOR_KIND_ENTRIES) 85 if (itemKind == ARRAY_ITERATOR_KIND_ENTRIES)
87 return CreateIteratorResultObject([elementKey, array[elementKey]], false); 86 return CreateIteratorResultObject([index, array[index]], false);
88 87
89 return CreateIteratorResultObject(elementKey, false); 88 return CreateIteratorResultObject(index, false);
90 } 89 }
91 90
92 function ArrayEntries() { 91 function ArrayEntries() {
93 return CreateArrayIterator(this, ARRAY_ITERATOR_KIND_ENTRIES); 92 return CreateArrayIterator(this, ARRAY_ITERATOR_KIND_ENTRIES);
94 } 93 }
95 94
96 function ArrayValues() { 95 function ArrayValues() {
97 return CreateArrayIterator(this, ARRAY_ITERATOR_KIND_VALUES); 96 return CreateArrayIterator(this, ARRAY_ITERATOR_KIND_VALUES);
98 } 97 }
99 98
(...skipping 18 matching lines...) Expand all
118 %CheckIsBootstrapping(); 117 %CheckIsBootstrapping();
119 118
120 InstallFunctions($Array.prototype, DONT_ENUM, $Array( 119 InstallFunctions($Array.prototype, DONT_ENUM, $Array(
121 'entries', ArrayEntries, 120 'entries', ArrayEntries,
122 'values', ArrayValues, 121 'values', ArrayValues,
123 'keys', ArrayKeys 122 'keys', ArrayKeys
124 )); 123 ));
125 } 124 }
126 125
127 ExtendArrayPrototype(); 126 ExtendArrayPrototype();
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/harmony/array-iterator.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698