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

Side by Side Diff: lib/compiler/implementation/util/link_implementation.dart

Issue 10917110: Revert "Collect the types used in is-checks in the resolver phase." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 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 | « lib/compiler/implementation/util/link.dart ('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 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 class LinkIterator<T> implements Iterator<T> { 5 class LinkIterator<T> implements Iterator<T> {
6 Link<T> current; 6 Link<T> current;
7 LinkIterator(Link<T> this.current); 7 LinkIterator(Link<T> this.current);
8 bool hasNext() => !current.isEmpty(); 8 bool hasNext() => !current.isEmpty();
9 T next() { 9 T next() {
10 T result = current.head; 10 T result = current.head;
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 Link<T> reversePrependAll(Link<T> from) { 63 Link<T> reversePrependAll(Link<T> from) {
64 if (from.isEmpty()) return this; 64 if (from.isEmpty()) return this;
65 return this.prepend(from.head).reversePrependAll(from.tail); 65 return this.prepend(from.head).reversePrependAll(from.tail);
66 } 66 }
67 67
68 List toList() => const []; 68 List toList() => const [];
69 69
70 bool isEmpty() => true; 70 bool isEmpty() => true;
71 71
72 void forEach(void f(T element)) {} 72 void forEach(void f(T element)) {}
73
74 bool equals(other) {
75 if (other is !Link<T>) return false;
76 return other.isEmpty();
77 }
78 } 73 }
79 74
80 class LinkEntry<T> implements Link<T> { 75 class LinkEntry<T> implements Link<T> {
81 final T head; 76 final T head;
82 Link<T> tail; 77 Link<T> tail;
83 78
84 LinkEntry(T this.head, Link<T> this.tail); 79 LinkEntry(T this.head, Link<T> this.tail);
85 80
86 Link<T> prepend(T element) { 81 Link<T> prepend(T element) {
87 // TODO(ahe): Use new Link<T>, but this cost 8% performance on VM. 82 // TODO(ahe): Use new Link<T>, but this cost 8% performance on VM.
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 list.addLast(link.head); 127 list.addLast(link.head);
133 } 128 }
134 return list; 129 return list;
135 } 130 }
136 131
137 void forEach(void f(T element)) { 132 void forEach(void f(T element)) {
138 for (Link<T> link = this; !link.isEmpty(); link = link.tail) { 133 for (Link<T> link = this; !link.isEmpty(); link = link.tail) {
139 f(link.head); 134 f(link.head);
140 } 135 }
141 } 136 }
142
143 bool equals(other) {
144 if (other is !Link<T>) return false;
145 Link<T> myElements = this;
146 while (!myElements.isEmpty() && !other.isEmpty()) {
147 if (myElements.head != other.head) {
148 return false;
149 }
150 myElements = myElements.tail;
151 other = other.tail;
152 }
153 return myElements.isEmpty() && other.isEmpty();
154 }
155 } 137 }
156 138
157 class LinkBuilderImplementation<T> implements LinkBuilder<T> { 139 class LinkBuilderImplementation<T> implements LinkBuilder<T> {
158 LinkEntry<T> head = null; 140 LinkEntry<T> head = null;
159 LinkEntry<T> lastLink = null; 141 LinkEntry<T> lastLink = null;
160 int length = 0; 142 int length = 0;
161 143
162 LinkBuilderImplementation(); 144 LinkBuilderImplementation();
163 145
164 Link<T> toLink() { 146 Link<T> toLink() {
165 if (head === null) return const LinkTail(); 147 if (head === null) return const LinkTail();
166 lastLink.tail = const LinkTail(); 148 lastLink.tail = const LinkTail();
167 Link<T> link = head; 149 Link<T> link = head;
168 lastLink = null; 150 lastLink = null;
169 head = null; 151 head = null;
170 return link; 152 return link;
171 } 153 }
172 154
173 void addLast(T t) { 155 void addLast(T t) {
174 length++; 156 length++;
175 LinkEntry<T> entry = new LinkEntry<T>(t, null); 157 LinkEntry<T> entry = new LinkEntry<T>(t, null);
176 if (head === null) { 158 if (head === null) {
177 head = entry; 159 head = entry;
178 } else { 160 } else {
179 lastLink.tail = entry; 161 lastLink.tail = entry;
180 } 162 }
181 lastLink = entry; 163 lastLink = entry;
182 } 164 }
183 } 165 }
OLDNEW
« no previous file with comments | « lib/compiler/implementation/util/link.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698