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

Side by Side Diff: sdk/lib/collection/list.dart

Issue 2998053002: Fix unnecessary use of this.length in ListMixin. (Closed)
Patch Set: Fix unnecessary use of this.length in ListMixin. Created 3 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 part of dart.collection; 5 part of dart.collection;
6 6
7 /** 7 /**
8 * Abstract implementation of a list. 8 * Abstract implementation of a list.
9 * 9 *
10 * `ListBase` can be used as a base class for implementing the `List` interface. 10 * `ListBase` can be used as a base class for implementing the `List` interface.
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 } 82 }
83 83
84 E get single { 84 E get single {
85 if (length == 0) throw IterableElementError.noElement(); 85 if (length == 0) throw IterableElementError.noElement();
86 if (length > 1) throw IterableElementError.tooMany(); 86 if (length > 1) throw IterableElementError.tooMany();
87 return this[0]; 87 return this[0];
88 } 88 }
89 89
90 bool contains(Object element) { 90 bool contains(Object element) {
91 int length = this.length; 91 int length = this.length;
92 for (int i = 0; i < this.length; i++) { 92 for (int i = 0; i < length; i++) {
93 if (this[i] == element) return true; 93 if (this[i] == element) return true;
94 if (length != this.length) { 94 if (length != this.length) {
95 throw new ConcurrentModificationError(this); 95 throw new ConcurrentModificationError(this);
96 } 96 }
97 } 97 }
98 return false; 98 return false;
99 } 99 }
100 100
101 bool every(bool test(E element)) { 101 bool every(bool test(E element)) {
102 int length = this.length; 102 int length = this.length;
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after
511 for (E element in iterable) { 511 for (E element in iterable) {
512 this[index++] = element; 512 this[index++] = element;
513 } 513 }
514 } 514 }
515 } 515 }
516 516
517 Iterable<E> get reversed => new ReversedListIterable<E>(this); 517 Iterable<E> get reversed => new ReversedListIterable<E>(this);
518 518
519 String toString() => IterableBase.iterableToFullString(this, '[', ']'); 519 String toString() => IterableBase.iterableToFullString(this, '[', ']');
520 } 520 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698