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

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: full version of previous patch. 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 | runtime/vm/method_recognizer.h » ('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 1d49d3b746dfbd89e26907d792db0239e35aa8ef..b6d1a2e31275d713538fb46c74ae8017178f5ed3 100644
--- a/runtime/lib/array.dart
+++ b/runtime/lib/array.dart
@@ -21,7 +21,20 @@ class _List<E> implements List<E> {
void _copyFromObjectArray(_List src,
int srcStart,
int dstStart,
- int count)
+ int count) {
+ if (count < 128) {
+ for (int i = 0; i < count; i++) {
+ this[dstStart + i] = src[srcStart + i];
+ }
+ } else {
+ _copyFromObjectArrayInternal(src, srcStart, dstStart, count);
+ }
+ }
+
+ void _copyFromObjectArrayInternal(_List src,
+ int srcStart,
+ int dstStart,
+ int count)
native "List_copyFromObjectArray";
void insert(int index, E element) {
@@ -66,22 +79,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) {
_copyFromObjectArray(iterable, skipCount, start, length);
+ } 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;
}
}
}
« no previous file with comments | « no previous file | runtime/vm/method_recognizer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698