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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/js/nodes.dart

Issue 661953003: Don't run through iterable twice. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 2 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 | 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) 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 part of js; 5 part of js;
6 6
7 abstract class NodeVisitor<T> { 7 abstract class NodeVisitor<T> {
8 T visitProgram(Program node); 8 T visitProgram(Program node);
9 9
10 T visitBlock(Block node); 10 T visitBlock(Block node);
(...skipping 923 matching lines...) Expand 10 before | Expand all | Expand 10 after
934 } 934 }
935 935
936 class ArrayInitializer extends Expression { 936 class ArrayInitializer extends Expression {
937 final int length; 937 final int length;
938 // We represent the array as sparse list of elements. Each element knows its 938 // We represent the array as sparse list of elements. Each element knows its
939 // position in the array. 939 // position in the array.
940 final List<ArrayElement> elements; 940 final List<ArrayElement> elements;
941 941
942 ArrayInitializer(this.length, this.elements); 942 ArrayInitializer(this.length, this.elements);
943 943
944 factory ArrayInitializer.from(Iterable<Expression> expressions) => 944 factory ArrayInitializer.from(Iterable<Expression> expressions) {
945 new ArrayInitializer(expressions.length, _convert(expressions)); 945 List<ArrayElement> elements = _convert(expressions);
946 return new ArrayInitializer(elements.length, elements);
947 }
946 948
947 accept(NodeVisitor visitor) => visitor.visitArrayInitializer(this); 949 accept(NodeVisitor visitor) => visitor.visitArrayInitializer(this);
948 950
949 void visitChildren(NodeVisitor visitor) { 951 void visitChildren(NodeVisitor visitor) {
950 for (ArrayElement element in elements) element.accept(visitor); 952 for (ArrayElement element in elements) element.accept(visitor);
951 } 953 }
952 954
953 ArrayInitializer _clone() => new ArrayInitializer(length, elements); 955 ArrayInitializer _clone() => new ArrayInitializer(length, elements);
954 956
955 int get precedenceLevel => PRIMARY; 957 int get precedenceLevel => PRIMARY;
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
1112 class Comment extends Statement { 1114 class Comment extends Statement {
1113 final String comment; 1115 final String comment;
1114 1116
1115 Comment(this.comment); 1117 Comment(this.comment);
1116 1118
1117 accept(NodeVisitor visitor) => visitor.visitComment(this); 1119 accept(NodeVisitor visitor) => visitor.visitComment(this);
1118 Comment _clone() => new Comment(comment); 1120 Comment _clone() => new Comment(comment);
1119 1121
1120 void visitChildren(NodeVisitor visitor) {} 1122 void visitChildren(NodeVisitor visitor) {}
1121 } 1123 }
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