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

Unified Diff: runtime/lib/array.dart

Issue 518273004: Don't always call _copyFromObjectArray. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 3 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: runtime/lib/array.dart
diff --git a/runtime/lib/array.dart b/runtime/lib/array.dart
index 1d49d3b746dfbd89e26907d792db0239e35aa8ef..0f06c9493a78360b713e552c0e7d4b8a4f697ec5 100644
--- a/runtime/lib/array.dart
+++ b/runtime/lib/array.dart
@@ -66,22 +66,21 @@ class _List<E> implements List<E> {
}
int length = end - start;
if (length == 0) return;
-
- if (ClassID.getID(iterable) == ClassID.cidOneByteString) {
+ if (identical(this, iterable)) {
+ Lists.copy(iterable, skipcount, this, start, length);
+ } else if (ClassID.getID(iterable) == ClassID.cidArray && length > 128) {
srdjan 2014/09/02 18:33:58 Please add parentheses.
_copyFromObjectArray(iterable, skipCount, start, length);
Lasse Reichstein Nielsen 2014/09/02 14:29:09 Good thing this wasn't called before due to the in
+ } else if (iterable is List) {
+ Lists.copy(iterable, skipCount, this, start, length);
} else {
- if (iterable is List) {
- Lists.copy(iterable, skipCount, this, start, length);
- } else {
- 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;
- }
+ 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;
}
}
}
@@ -104,7 +103,13 @@ class _List<E> implements List<E> {
int length = end - start;
if (start == end) return <E>[];
List list = new _List(length);
- list._copyFromObjectArray(this, start, 0, length);
+ if (length < 128) {
Vyacheslav Egorov (Google) 2014/09/02 14:31:15 I don't like that this is repeated. Can we have
+ for (int i = 0; i < length; i++) {
+ list[i] = this[start + i];
+ }
+ } else {
+ list._copyFromObjectArray(this, start, 0, length);
+ }
var result = new _GrowableList<E>.withData(list);
result._setLength(length);
return result;
@@ -257,7 +262,13 @@ class _List<E> implements List<E> {
var length = this.length;
if (length > 0) {
var result = growable ? new _List(length) : new _List<E>(length);
- result._copyFromObjectArray(this, 0, 0, length);
+ if (length < 128) {
+ for (int i = 0; i < length; i++) {
+ result[i] = this[i];
+ }
+ } else {
+ result._copyFromObjectArray(this, 0, 0, length);
+ }
if (growable) {
result = new _GrowableList<E>.withData(result);
result._setLength(length);
« 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