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

Unified Diff: sdk/lib/collection/list.dart

Issue 135533002: [Core] Optimize List (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: integrate feedback Created 6 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/collection/list.dart
diff --git a/sdk/lib/collection/list.dart b/sdk/lib/collection/list.dart
index d4dac6a4e9ccb9b436ff68cf1237de009b59c6ac..7669a70a5bba94806fb18257b019807330157ae4 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,9 @@ 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();
- } 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();
- }
+ if (length == 0) return "";
+ StringBuffer buffer = new StringBuffer()..writeAll(this, separator);
+ return buffer.toString();
}
Iterable<E> where(bool test(E element)) => new WhereIterable<E>(this, test);
« 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