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

Unified Diff: pkg/compiler/lib/src/util/link_implementation.dart

Issue 1299393002: dart2js: Just because it's slow doesn't mean it has to be dumb. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 4 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 | « pkg/compiler/lib/src/util/link.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/util/link_implementation.dart
diff --git a/pkg/compiler/lib/src/util/link_implementation.dart b/pkg/compiler/lib/src/util/link_implementation.dart
index 7cea7d929d14ebdba2462700c406be0651c5dda3..74d9f231fa8c3495f5460be462b992c4ce43c3e6 100644
--- a/pkg/compiler/lib/src/util/link_implementation.dart
+++ b/pkg/compiler/lib/src/util/link_implementation.dart
@@ -71,7 +71,7 @@ class LinkEntry<T> extends Link<T> {
void printOn(StringBuffer buffer, [separatedBy]) {
buffer.write(head);
if (separatedBy == null) separatedBy = '';
- for (Link link = tail; !link.isEmpty; link = link.tail) {
+ for (Link link = tail; link.isNotEmpty; link = link.tail) {
buffer.write(separatedBy);
buffer.write(link.head);
}
@@ -87,7 +87,7 @@ class LinkEntry<T> extends Link<T> {
Link<T> reverse() {
Link<T> result = const Link();
- for (Link<T> link = this; !link.isEmpty; link = link.tail) {
+ for (Link<T> link = this; link.isNotEmpty; link = link.tail) {
result = result.prepend(link.head);
}
return result;
@@ -95,7 +95,7 @@ class LinkEntry<T> extends Link<T> {
Link<T> reversePrependAll(Link<T> from) {
Link<T> result;
- for (result = this; !from.isEmpty; from = from.tail) {
+ for (result = this; from.isNotEmpty; from = from.tail) {
result = result.prepend(from.head);
}
return result;
@@ -113,9 +113,10 @@ class LinkEntry<T> extends Link<T> {
}
bool get isEmpty => false;
+ bool get isNotEmpty => true;
void forEach(void f(T element)) {
- for (Link<T> link = this; !link.isEmpty; link = link.tail) {
+ for (Link<T> link = this; link.isNotEmpty; link = link.tail) {
f(link.head);
}
}
@@ -123,7 +124,7 @@ class LinkEntry<T> extends Link<T> {
bool operator ==(other) {
if (other is !Link<T>) return false;
Link<T> myElements = this;
- while (!myElements.isEmpty && !other.isEmpty) {
+ while (myElements.isNotEmpty && other.isNotEmpty) {
if (myElements.head != other.head) {
return false;
}
@@ -135,12 +136,18 @@ class LinkEntry<T> extends Link<T> {
int get hashCode => throw new UnsupportedError('LinkEntry.hashCode');
- int slowLength() => 1 + tail.slowLength();
+ int slowLength() {
+ int length = 0;
+ for (Link current = this; current.isNotEmpty; current = current.tail) {
+ ++length;
+ }
+ return length;
+ }
Link copyWithout(e) {
LinkBuilder copy = new LinkBuilder();
Link link = this;
- for (; !link.isEmpty; link = link.tail) {
+ for (; link.isNotEmpty; link = link.tail) {
if (link.head != e) {
copy.addLast(link.head);
}
@@ -170,7 +177,7 @@ class LinkBuilderImplementation<T> implements LinkBuilder<T> {
List<T> list = new List<T>(length);
int index = 0;
Link<T> link = head;
- while (!link.isEmpty) {
+ while (link.isNotEmpty) {
list[index] = link.head;
link = link.tail;
index++;
« no previous file with comments | « pkg/compiler/lib/src/util/link.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698