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

Unified Diff: runtime/lib/array.dart

Issue 26976002: Optimize some collection operations. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix typo. Created 7 years, 2 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 | sdk/lib/collection/hash_set.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/lib/array.dart
diff --git a/runtime/lib/array.dart b/runtime/lib/array.dart
index a953f71ea3f1fd6c675a2c3ca7c7a4f16ba618e4..a0fb5f9f94ceb176b8b9ce83389d5e9731b49887 100644
--- a/runtime/lib/array.dart
+++ b/runtime/lib/array.dart
@@ -77,17 +77,19 @@ class _List<E> implements List<E> {
if (iterable is _List) {
_copyFromObjectArray(iterable, skipCount, start, length);
} else {
- List otherList;
- int otherStart;
if (iterable is List) {
- otherList = iterable;
- otherStart = skipCount;
+ Arrays.copy(iterable, skipCount, this, start, length);
} else {
- otherList =
- iterable.skip(skipCount).take(length).toList(growable: false);
- otherStart = 0;
+ Iterator it = iterable.iterator;
+ while (skipCount > 0) {
+ if (!it.moveNext()) return;
+ skipCount--;
+ }
+ for (int i = start; i < end; i++) {
+ if (!it.moveNext()) return;
+ this[i] = it.current;
+ }
}
- Arrays.copy(otherList, otherStart, this, start, length);
}
}
« no previous file with comments | « no previous file | sdk/lib/collection/hash_set.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698