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

Side by Side Diff: pkg/compiler/lib/src/util/link_implementation.dart

Issue 2033873002: use const Link so that empty Link is always identical (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 6 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
« no previous file with comments | « no previous file | 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 part of util_implementation; 5 part of util_implementation;
6 6
7 class LinkIterator<T> implements Iterator<T> { 7 class LinkIterator<T> implements Iterator<T> {
8 T _current; 8 T _current;
9 Link<T> _link; 9 Link<T> _link;
10 10
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 Iterator<T> get iterator { 54 Iterator<T> get iterator {
55 return new MappedLinkIterator<S, T>(_link, _transformation); 55 return new MappedLinkIterator<S, T>(_link, _transformation);
56 } 56 }
57 } 57 }
58 58
59 class LinkEntry<T> extends Link<T> { 59 class LinkEntry<T> extends Link<T> {
60 final T head; 60 final T head;
61 Link<T> tail; 61 Link<T> tail;
62 62
63 LinkEntry(T this.head, [Link<T> tail]) 63 LinkEntry(T this.head, [Link<T> tail])
64 : this.tail = ((tail == null) ? new Link<T>() : tail); 64 : this.tail = ((tail == null) ? const Link() : tail);
65 65
66 Link<T> prepend(T element) { 66 Link<T> prepend(T element) {
67 // TODO(ahe): Use new Link<T>, but this cost 8% performance on VM. 67 // TODO(ahe): Use new Link<T>, but this cost 8% performance on VM.
68 return new LinkEntry<T>(element, this); 68 return new LinkEntry<T>(element, this);
69 } 69 }
70 70
71 void printOn(StringBuffer buffer, [separatedBy]) { 71 void printOn(StringBuffer buffer, [separatedBy]) {
72 buffer.write(head); 72 buffer.write(head);
73 if (separatedBy == null) separatedBy = ''; 73 if (separatedBy == null) separatedBy = '';
74 for (Link link = tail; link.isNotEmpty; link = link.tail) { 74 for (Link link = tail; link.isNotEmpty; link = link.tail) {
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 } 209 }
210 throw new StateError("no elements"); 210 throw new StateError("no elements");
211 } 211 }
212 212
213 void clear() { 213 void clear() {
214 head = null; 214 head = null;
215 lastLink = null; 215 lastLink = null;
216 length = 0; 216 length = 0;
217 } 217 }
218 } 218 }
OLDNEW
« 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