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

Side by Side Diff: pkg/analyzer/lib/dart/ast/ast.dart

Issue 1955373003: Convert some for-in loops for performance (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 4 years, 7 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 | pkg/analyzer/lib/dart/ast/token.dart » ('j') | 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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 /** 5 /**
6 * Defines the AST model. The AST (Abstract Syntax Tree) model describes the 6 * Defines the AST model. The AST (Abstract Syntax Tree) model describes the
7 * syntactic (as opposed to semantic) structure of Dart code. The semantic 7 * syntactic (as opposed to semantic) structure of Dart code. The semantic
8 * structure of the code is modeled by the 8 * structure of the code is modeled by the
9 * [element model](../element/element.dart). 9 * [element model](../element/element.dart).
10 * 10 *
(...skipping 4561 matching lines...) Expand 10 before | Expand all | Expand 10 after
4572 return compare; 4572 return compare;
4573 } 4573 }
4574 } 4574 }
4575 } 4575 }
4576 // 4576 //
4577 // hides and shows 4577 // hides and shows
4578 // 4578 //
4579 NodeList<Combinator> combinators1 = import1.combinators; 4579 NodeList<Combinator> combinators1 = import1.combinators;
4580 List<String> allHides1 = new List<String>(); 4580 List<String> allHides1 = new List<String>();
4581 List<String> allShows1 = new List<String>(); 4581 List<String> allShows1 = new List<String>();
4582 for (Combinator combinator in combinators1) { 4582 int length1 = combinators1.length;
4583 for (int i = 0; i < length1; i++) {
4584 Combinator combinator = combinators1[i];
4583 if (combinator is HideCombinator) { 4585 if (combinator is HideCombinator) {
4584 NodeList<SimpleIdentifier> hides = combinator.hiddenNames; 4586 NodeList<SimpleIdentifier> hides = combinator.hiddenNames;
4585 for (SimpleIdentifier simpleIdentifier in hides) { 4587 int hideLength = hides.length;
4588 for (int j = 0; j < hideLength; j++) {
4589 SimpleIdentifier simpleIdentifier = hides[j];
4586 allHides1.add(simpleIdentifier.name); 4590 allHides1.add(simpleIdentifier.name);
4587 } 4591 }
4588 } else { 4592 } else {
4589 NodeList<SimpleIdentifier> shows = 4593 NodeList<SimpleIdentifier> shows =
4590 (combinator as ShowCombinator).shownNames; 4594 (combinator as ShowCombinator).shownNames;
4591 for (SimpleIdentifier simpleIdentifier in shows) { 4595 int showLength = shows.length;
4596 for (int j = 0; j < showLength; j++) {
4597 SimpleIdentifier simpleIdentifier = shows[j];
4592 allShows1.add(simpleIdentifier.name); 4598 allShows1.add(simpleIdentifier.name);
4593 } 4599 }
4594 } 4600 }
4595 } 4601 }
4596 NodeList<Combinator> combinators2 = import2.combinators; 4602 NodeList<Combinator> combinators2 = import2.combinators;
4597 List<String> allHides2 = new List<String>(); 4603 List<String> allHides2 = new List<String>();
4598 List<String> allShows2 = new List<String>(); 4604 List<String> allShows2 = new List<String>();
4599 for (Combinator combinator in combinators2) { 4605 int length2 = combinators2.length;
4606 for (int i = 0; i < length2; i++) {
4607 Combinator combinator = combinators2[i];
4600 if (combinator is HideCombinator) { 4608 if (combinator is HideCombinator) {
4601 NodeList<SimpleIdentifier> hides = combinator.hiddenNames; 4609 NodeList<SimpleIdentifier> hides = combinator.hiddenNames;
4602 for (SimpleIdentifier simpleIdentifier in hides) { 4610 int hideLength = hides.length;
4611 for (int j = 0; j < hideLength; j++) {
4612 SimpleIdentifier simpleIdentifier = hides[j];
4603 allHides2.add(simpleIdentifier.name); 4613 allHides2.add(simpleIdentifier.name);
4604 } 4614 }
4605 } else { 4615 } else {
4606 NodeList<SimpleIdentifier> shows = 4616 NodeList<SimpleIdentifier> shows =
4607 (combinator as ShowCombinator).shownNames; 4617 (combinator as ShowCombinator).shownNames;
4608 for (SimpleIdentifier simpleIdentifier in shows) { 4618 int showLength = shows.length;
4619 for (int j = 0; j < showLength; j++) {
4620 SimpleIdentifier simpleIdentifier = shows[j];
4609 allShows2.add(simpleIdentifier.name); 4621 allShows2.add(simpleIdentifier.name);
4610 } 4622 }
4611 } 4623 }
4612 } 4624 }
4613 // test lengths of combinator lists first 4625 // test lengths of combinator lists first
4614 if (allHides1.length != allHides2.length) { 4626 if (allHides1.length != allHides2.length) {
4615 return allHides1.length - allHides2.length; 4627 return allHides1.length - allHides2.length;
4616 } 4628 }
4617 if (allShows1.length != allShows2.length) { 4629 if (allShows1.length != allShows2.length) {
4618 return allShows1.length - allShows2.length; 4630 return allShows1.length - allShows2.length;
(...skipping 3608 matching lines...) Expand 10 before | Expand all | Expand 10 after
8227 /** 8239 /**
8228 * Return the 'yield' keyword. 8240 * Return the 'yield' keyword.
8229 */ 8241 */
8230 Token get yieldKeyword; 8242 Token get yieldKeyword;
8231 8243
8232 /** 8244 /**
8233 * Return the 'yield' keyword to the given [token]. 8245 * Return the 'yield' keyword to the given [token].
8234 */ 8246 */
8235 void set yieldKeyword(Token token); 8247 void set yieldKeyword(Token token);
8236 } 8248 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/lib/dart/ast/token.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698