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

Side by Side Diff: tools/dom/templates/immutable_list_mixin.darttemplate

Issue 23534050: Make direct calls to _nativeIndexedGetter in "get last" "get first" "get single" instead of calling… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 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 | « tools/dom/scripts/templateloader.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // -- start List<$E> mixins. 1 // -- start List<$E> mixins.
2 // $E is the element type. 2 // $E is the element type.
3 3
4 $if DEFINE_LENGTH_AS_NUM_ITEMS 4 $if DEFINE_LENGTH_AS_NUM_ITEMS
5 // SVG Collections expose numberOfItems rather than length. 5 // SVG Collections expose numberOfItems rather than length.
6 int get length => numberOfItems; 6 int get length => numberOfItems;
7 $endif 7 $endif
8 8
9 $if DEFINE_LENGTH_SETTER 9 $if DEFINE_LENGTH_SETTER
10 void set length(int value) { 10 void set length(int value) {
11 throw new UnsupportedError("Cannot resize immutable List."); 11 throw new UnsupportedError("Cannot resize immutable List.");
12 } 12 }
13 $endif 13 $endif
14 14
15 $E get first { 15 $E get first {
16 if (this.length > 0) { 16 if (this.length > 0) {
17 $if DART2JS 17 $if DART2JS
18 return JS('$E', '#[0]', this); 18 return JS('$E', '#[0]', this);
19 $else 19 $else
20 $if USE_NATIVE_INDEXED_GETTER
21 return $GETTER(0);
22 $else
20 return this[0]; 23 return this[0];
21 $endif 24 $endif
25 $endif
22 } 26 }
23 throw new StateError("No elements"); 27 throw new StateError("No elements");
24 } 28 }
25 29
26 $E get last { 30 $E get last {
27 int len = this.length; 31 int len = this.length;
28 if (len > 0) { 32 if (len > 0) {
29 $if DART2JS 33 $if DART2JS
30 return JS('$E', '#[#]', this, len - 1); 34 return JS('$E', '#[#]', this, len - 1);
31 $else 35 $else
36 $if USE_NATIVE_INDEXED_GETTER
37 return $GETTER(len - 1);
38 $else
32 return this[len - 1]; 39 return this[len - 1];
33 $endif 40 $endif
41 $endif
34 } 42 }
35 throw new StateError("No elements"); 43 throw new StateError("No elements");
36 } 44 }
37 45
38 $E get single { 46 $E get single {
39 int len = this.length; 47 int len = this.length;
40 if (len == 1) { 48 if (len == 1) {
41 $if DART2JS 49 $if DART2JS
42 return JS('$E', '#[0]', this); 50 return JS('$E', '#[0]', this);
43 $else 51 $else
52 $if USE_NATIVE_INDEXED_GETTER
53 return $GETTER(0);
54 $else
44 return this[0]; 55 return this[0];
45 $endif 56 $endif
57 $endif
46 } 58 }
47 if (len == 0) throw new StateError("No elements"); 59 if (len == 0) throw new StateError("No elements");
48 throw new StateError("More than one element"); 60 throw new StateError("More than one element");
49 } 61 }
50 62
51 $E elementAt(int index) => this[index]; 63 $E elementAt(int index) => this[index];
52 // -- end List<$E> mixins. 64 // -- end List<$E> mixins.
OLDNEW
« no previous file with comments | « tools/dom/scripts/templateloader.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698