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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | runtime/vm/method_recognizer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 5
6 // TODO(srdjan): Use shared array implementation. 6 // TODO(srdjan): Use shared array implementation.
7 class _List<E> implements List<E> { 7 class _List<E> implements List<E> {
8 8
9 factory _List(length) native "List_allocate"; 9 factory _List(length) native "List_allocate";
10 10
11 E operator [](int index) native "List_getIndexed"; 11 E operator [](int index) native "List_getIndexed";
12 12
13 void operator []=(int index, E value) native "List_setIndexed"; 13 void operator []=(int index, E value) native "List_setIndexed";
14 14
15 String toString() { 15 String toString() {
16 return ListBase.listToString(this); 16 return ListBase.listToString(this);
17 } 17 }
18 18
19 int get length native "List_getLength"; 19 int get length native "List_getLength";
20 20
21 void _copyFromObjectArray(_List src, 21 void _copyFromObjectArray(_List src,
22 int srcStart, 22 int srcStart,
23 int dstStart, 23 int dstStart,
24 int count) 24 int count) {
25 if (count < 128) {
26 for (int i = 0; i < count; i++) {
27 this[dstStart + i] = src[srcStart + i];
28 }
29 } else {
30 _copyFromObjectArrayInternal(src, srcStart, dstStart, count);
31 }
32 }
33
34 void _copyFromObjectArrayInternal(_List src,
35 int srcStart,
36 int dstStart,
37 int count)
25 native "List_copyFromObjectArray"; 38 native "List_copyFromObjectArray";
26 39
27 void insert(int index, E element) { 40 void insert(int index, E element) {
28 throw NonGrowableListError.add(); 41 throw NonGrowableListError.add();
29 } 42 }
30 43
31 void insertAll(int index, Iterable<E> iterable) { 44 void insertAll(int index, Iterable<E> iterable) {
32 throw NonGrowableListError.add(); 45 throw NonGrowableListError.add();
33 } 46 }
34 47
(...skipping 24 matching lines...) Expand all
59 // List interface. 72 // List interface.
60 void setRange(int start, int end, Iterable<E> iterable, [int skipCount = 0]) { 73 void setRange(int start, int end, Iterable<E> iterable, [int skipCount = 0]) {
61 if (start < 0 || start > this.length) { 74 if (start < 0 || start > this.length) {
62 throw new RangeError.range(start, 0, this.length); 75 throw new RangeError.range(start, 0, this.length);
63 } 76 }
64 if (end < start || end > this.length) { 77 if (end < start || end > this.length) {
65 throw new RangeError.range(end, start, this.length); 78 throw new RangeError.range(end, start, this.length);
66 } 79 }
67 int length = end - start; 80 int length = end - start;
68 if (length == 0) return; 81 if (length == 0) return;
69 82 if (identical(this, iterable)) {
70 if (ClassID.getID(iterable) == ClassID.cidOneByteString) { 83 Lists.copy(iterable, skipCount, this, start, length);
84 } else if (ClassID.getID(iterable) == ClassID.cidArray) {
71 _copyFromObjectArray(iterable, skipCount, start, length); 85 _copyFromObjectArray(iterable, skipCount, start, length);
86 } else if (iterable is List) {
87 Lists.copy(iterable, skipCount, this, start, length);
72 } else { 88 } else {
73 if (iterable is List) { 89 Iterator it = iterable.iterator;
74 Lists.copy(iterable, skipCount, this, start, length); 90 while (skipCount > 0) {
75 } else { 91 if (!it.moveNext()) return;
76 Iterator it = iterable.iterator; 92 skipCount--;
77 while (skipCount > 0) { 93 }
78 if (!it.moveNext()) return; 94 for (int i = start; i < end; i++) {
79 skipCount--; 95 if (!it.moveNext()) return;
80 } 96 this[i] = it.current;
81 for (int i = start; i < end; i++) {
82 if (!it.moveNext()) return;
83 this[i] = it.current;
84 }
85 } 97 }
86 } 98 }
87 } 99 }
88 100
89 void removeRange(int start, int end) { 101 void removeRange(int start, int end) {
90 throw NonGrowableListError.remove(); 102 throw NonGrowableListError.remove();
91 } 103 }
92 104
93 void replaceRange(int start, int end, Iterable<E> iterable) { 105 void replaceRange(int start, int end, Iterable<E> iterable) {
94 throw NonGrowableListError.remove(); 106 throw NonGrowableListError.remove();
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after
558 bool moveNext() { 570 bool moveNext() {
559 if (_index >= _length) { 571 if (_index >= _length) {
560 _current = null; 572 _current = null;
561 return false; 573 return false;
562 } 574 }
563 _current = _array[_index]; 575 _current = _array[_index];
564 _index++; 576 _index++;
565 return true; 577 return true;
566 } 578 }
567 } 579 }
OLDNEW
« 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