Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 | 5 |
| 6 // TODO(srdjan): Use shared array implementation. | 6 // TODO(srdjan): Use shared array implementation. |
| 7 class _List<E> implements List<E> { | 7 class _List<E> implements List<E> { |
| 8 | 8 |
| 9 factory _List(length) native "List_allocate"; | 9 factory _List(length) native "List_allocate"; |
| 10 | 10 |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 110 return result; | 110 return result; |
| 111 } | 111 } |
| 112 | 112 |
| 113 // Iterable interface. | 113 // Iterable interface. |
| 114 | 114 |
| 115 bool contains(Object element) { | 115 bool contains(Object element) { |
| 116 return IterableMixinWorkaround.contains(this, element); | 116 return IterableMixinWorkaround.contains(this, element); |
| 117 } | 117 } |
| 118 | 118 |
| 119 void forEach(f(E element)) { | 119 void forEach(f(E element)) { |
| 120 IterableMixinWorkaround.forEach(this, f); | 120 for (int i = 0; i < length; i++) { |
|
kasperl
2014/08/28 13:45:18
Does it make a difference if you cache length in a
Anders Johnsen
2014/08/28 14:20:12
Done.
| |
| 121 f(this[i]); | |
| 122 } | |
| 121 } | 123 } |
| 122 | 124 |
| 123 String join([String separator = ""]) { | 125 String join([String separator = ""]) { |
| 124 return IterableMixinWorkaround.joinList(this, separator); | 126 return IterableMixinWorkaround.joinList(this, separator); |
| 125 } | 127 } |
| 126 | 128 |
| 127 Iterable map(f(E element)) { | 129 Iterable map(f(E element)) { |
| 128 return IterableMixinWorkaround.mapList(this, f); | 130 return IterableMixinWorkaround.mapList(this, f); |
| 129 } | 131 } |
| 130 | 132 |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 366 return new IterableMixinWorkaround<E>().getRangeList(this, start, end); | 368 return new IterableMixinWorkaround<E>().getRangeList(this, start, end); |
| 367 } | 369 } |
| 368 | 370 |
| 369 // Collection interface. | 371 // Collection interface. |
| 370 | 372 |
| 371 bool contains(Object element) { | 373 bool contains(Object element) { |
| 372 return IterableMixinWorkaround.contains(this, element); | 374 return IterableMixinWorkaround.contains(this, element); |
| 373 } | 375 } |
| 374 | 376 |
| 375 void forEach(f(E element)) { | 377 void forEach(f(E element)) { |
| 376 IterableMixinWorkaround.forEach(this, f); | 378 IterableMixinWorkaround.forEach(this, f); |
|
Lasse Reichstein Nielsen
2014/08/28 13:47:42
Consider doing the same thing here.
Anders Johnsen
2014/08/28 14:20:12
Done.
| |
| 377 } | 379 } |
| 378 | 380 |
| 379 Iterable map(f(E element)) { | 381 Iterable map(f(E element)) { |
| 380 return IterableMixinWorkaround.mapList(this, f); | 382 return IterableMixinWorkaround.mapList(this, f); |
| 381 } | 383 } |
| 382 | 384 |
| 383 String join([String separator = ""]) { | 385 String join([String separator = ""]) { |
| 384 return IterableMixinWorkaround.joinList(this, separator); | 386 return IterableMixinWorkaround.joinList(this, separator); |
| 385 } | 387 } |
| 386 | 388 |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 556 } | 558 } |
| 557 _position = _length; | 559 _position = _length; |
| 558 _current = null; | 560 _current = null; |
| 559 return false; | 561 return false; |
| 560 } | 562 } |
| 561 | 563 |
| 562 E get current { | 564 E get current { |
| 563 return _current; | 565 return _current; |
| 564 } | 566 } |
| 565 } | 567 } |
| OLD | NEW |