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

Side by Side Diff: pkg/analyzer/lib/src/generated/element_resolver.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 | « pkg/analyzer/lib/src/dart/ast/ast.dart ('k') | pkg/analyzer/lib/src/generated/resolver.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 library analyzer.src.generated.element_resolver; 5 library analyzer.src.generated.element_resolver;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 8
9 import 'package:analyzer/dart/ast/ast.dart'; 9 import 'package:analyzer/dart/ast/ast.dart';
10 import 'package:analyzer/dart/ast/token.dart'; 10 import 'package:analyzer/dart/ast/token.dart';
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after
463 Object visitFunctionTypedFormalParameter(FunctionTypedFormalParameter node) { 463 Object visitFunctionTypedFormalParameter(FunctionTypedFormalParameter node) {
464 _resolveMetadataForParameter(node.element, node); 464 _resolveMetadataForParameter(node.element, node);
465 return null; 465 return null;
466 } 466 }
467 467
468 @override 468 @override
469 Object visitImportDirective(ImportDirective node) { 469 Object visitImportDirective(ImportDirective node) {
470 SimpleIdentifier prefixNode = node.prefix; 470 SimpleIdentifier prefixNode = node.prefix;
471 if (prefixNode != null) { 471 if (prefixNode != null) {
472 String prefixName = prefixNode.name; 472 String prefixName = prefixNode.name;
473 for (PrefixElement prefixElement in _definingLibrary.prefixes) { 473 List<PrefixElement> prefixes = _definingLibrary.prefixes;
474 int count = prefixes.length;
475 for (int i = 0; i < count; i++) {
476 PrefixElement prefixElement = prefixes[i];
474 if (prefixElement.displayName == prefixName) { 477 if (prefixElement.displayName == prefixName) {
475 prefixNode.staticElement = prefixElement; 478 prefixNode.staticElement = prefixElement;
476 break; 479 break;
477 } 480 }
478 } 481 }
479 } 482 }
480 ImportElement importElement = node.element; 483 ImportElement importElement = node.element;
481 if (importElement != null) { 484 if (importElement != null) {
482 // The element is null when the URI is invalid 485 // The element is null when the URI is invalid
483 LibraryElement library = importElement.importedLibrary; 486 LibraryElement library = importElement.importedLibrary;
(...skipping 900 matching lines...) Expand 10 before | Expand all | Expand 10 after
1384 !(element is ClassElement && element.isOrInheritsProxy); 1387 !(element is ClassElement && element.isOrInheritsProxy);
1385 1388
1386 /** 1389 /**
1387 * Look for any declarations of the given [identifier] that are imported using 1390 * Look for any declarations of the given [identifier] that are imported using
1388 * a prefix. Return the element that was found, or `null` if the name is not 1391 * a prefix. Return the element that was found, or `null` if the name is not
1389 * imported using a prefix. 1392 * imported using a prefix.
1390 */ 1393 */
1391 Element _findImportWithoutPrefix(SimpleIdentifier identifier) { 1394 Element _findImportWithoutPrefix(SimpleIdentifier identifier) {
1392 Element element = null; 1395 Element element = null;
1393 Scope nameScope = _resolver.nameScope; 1396 Scope nameScope = _resolver.nameScope;
1394 for (ImportElement importElement in _definingLibrary.imports) { 1397 List<ImportElement> imports = _definingLibrary.imports;
1398 int length = imports.length;
1399 for (int i = 0; i < length; i++) {
1400 ImportElement importElement = imports[i];
1395 PrefixElement prefixElement = importElement.prefix; 1401 PrefixElement prefixElement = importElement.prefix;
1396 if (prefixElement != null) { 1402 if (prefixElement != null) {
1397 Identifier prefixedIdentifier = new PrefixedIdentifierImpl.temp( 1403 Identifier prefixedIdentifier = new PrefixedIdentifierImpl.temp(
1398 new SimpleIdentifierImpl(new StringToken(TokenType.STRING, 1404 new SimpleIdentifierImpl(new StringToken(TokenType.STRING,
1399 prefixElement.name, prefixElement.nameOffset)), 1405 prefixElement.name, prefixElement.nameOffset)),
1400 identifier); 1406 identifier);
1401 Element importedElement = 1407 Element importedElement =
1402 nameScope.lookup(prefixedIdentifier, _definingLibrary); 1408 nameScope.lookup(prefixedIdentifier, _definingLibrary);
1403 if (importedElement != null) { 1409 if (importedElement != null) {
1404 if (element == null) { 1410 if (element == null) {
(...skipping 1182 matching lines...) Expand 10 before | Expand all | Expand 10 after
2587 2593
2588 @override 2594 @override
2589 Element get staticElement => null; 2595 Element get staticElement => null;
2590 2596
2591 @override 2597 @override
2592 dynamic/*=E*/ accept/*<E>*/(AstVisitor/*<E>*/ visitor) => null; 2598 dynamic/*=E*/ accept/*<E>*/(AstVisitor/*<E>*/ visitor) => null;
2593 2599
2594 @override 2600 @override
2595 void visitChildren(AstVisitor visitor) {} 2601 void visitChildren(AstVisitor visitor) {}
2596 } 2602 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/dart/ast/ast.dart ('k') | pkg/analyzer/lib/src/generated/resolver.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698