Chromium Code Reviews| Index: sdk/lib/collection/list.dart |
| diff --git a/sdk/lib/collection/list.dart b/sdk/lib/collection/list.dart |
| index d4dac6a4e9ccb9b436ff68cf1237de009b59c6ac..3b326444322e0bc8e29eaa7102d14ab71ad26258 100644 |
| --- a/sdk/lib/collection/list.dart |
| +++ b/sdk/lib/collection/list.dart |
| @@ -81,7 +81,7 @@ abstract class ListMixin<E> implements List<E> { |
| bool contains(Object element) { |
| int length = this.length; |
| - for (int i = 0; i < length; i++) { |
| + for (int i = 0; i < this.length; i++) { |
| if (this[i] == element) return true; |
| if (length != this.length) { |
| throw new ConcurrentModificationError(this); |
| @@ -160,32 +160,14 @@ abstract class ListMixin<E> implements List<E> { |
| } |
| String join([String separator = ""]) { |
| - int length = this.length; |
| - if (!separator.isEmpty) { |
| - if (length == 0) return ""; |
| - String first = "${this[0]}"; |
| - if (length != this.length) { |
| - throw new ConcurrentModificationError(this); |
| - } |
| - StringBuffer buffer = new StringBuffer(first); |
| - for (int i = 1; i < length; i++) { |
| - buffer.write(separator); |
| - buffer.write(this[i]); |
| - if (length != this.length) { |
| - throw new ConcurrentModificationError(this); |
| - } |
| - } |
| - return buffer.toString(); |
| + if (this.length == 0) return ""; |
| + StringBuffer buffer = new StringBuffer(); |
| + if (separator.isEmpty) { |
|
Lasse Reichstein Nielsen
2014/02/05 10:41:00
Just checked the StringBuffer code: This "if" isn'
vicb
2014/02/06 12:42:22
Indeed. Thank for the tip.
|
| + buffer.writeAll(this); |
| } else { |
| - StringBuffer buffer = new StringBuffer(); |
| - for (int i = 0; i < length; i++) { |
| - buffer.write(this[i]); |
| - if (length != this.length) { |
| - throw new ConcurrentModificationError(this); |
| - } |
| - } |
| - return buffer.toString(); |
| + buffer.writeAll(this, separator); |
| } |
| + return buffer.toString(); |
| } |
| Iterable<E> where(bool test(E element)) => new WhereIterable<E>(this, test); |