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

Unified Diff: pkg/analyzer/lib/src/generated/resolver.dart

Issue 1821543002: Issue 26044. Cache and use LibraryElementImpl.exportNamespace. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 9 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
Index: pkg/analyzer/lib/src/generated/resolver.dart
diff --git a/pkg/analyzer/lib/src/generated/resolver.dart b/pkg/analyzer/lib/src/generated/resolver.dart
index 651c4bf2f9bdd0cc996475835f96677799c32f53..3ea46e098da240b47f2bcacd694c8dce007fd625 100644
--- a/pkg/analyzer/lib/src/generated/resolver.dart
+++ b/pkg/analyzer/lib/src/generated/resolver.dart
@@ -6609,10 +6609,9 @@ class NamespaceBuilder {
//
return Namespace.EMPTY;
}
- HashMap<String, Element> definedNames =
- _createExportMapping(exportedLibrary, new HashSet<LibraryElement>());
- definedNames = _applyCombinators(definedNames, element.combinators);
- return new Namespace(definedNames);
+ HashMap<String, Element> exportedNames = _getExportMapping(exportedLibrary);
+ exportedNames = _applyCombinators(exportedNames, element.combinators);
+ return new Namespace(exportedNames);
}
/**
@@ -6621,9 +6620,10 @@ class NamespaceBuilder {
* @param library the library whose export namespace is to be created
* @return the export namespace that was created
*/
- Namespace createExportNamespaceForLibrary(LibraryElement library) =>
- new Namespace(
- _createExportMapping(library, new HashSet<LibraryElement>()));
+ Namespace createExportNamespaceForLibrary(LibraryElement library) {
+ HashMap<String, Element> exportedNames = _getExportMapping(library);
+ return new Namespace(exportedNames);
+ }
/**
* Create a namespace representing the import namespace of the given library.
@@ -6640,11 +6640,10 @@ class NamespaceBuilder {
//
return Namespace.EMPTY;
}
- HashMap<String, Element> definedNames =
- _createExportMapping(importedLibrary, new HashSet<LibraryElement>());
- definedNames = _applyCombinators(definedNames, element.combinators);
- definedNames = _applyPrefix(definedNames, element.prefix);
- return new Namespace(definedNames);
+ HashMap<String, Element> exportedNames = _getExportMapping(importedLibrary);
+ exportedNames = _applyCombinators(exportedNames, element.combinators);
+ exportedNames = _applyPrefix(exportedNames, element.prefix);
+ return new Namespace(exportedNames);
}
/**
@@ -6759,6 +6758,19 @@ class NamespaceBuilder {
}
}
+ HashMap<String, Element> _getExportMapping(LibraryElement library) {
+ if (library is LibraryElementImpl) {
+ if (library.exportNamespace != null) {
+ return library.exportNamespace.definedNames;
+ } else {
+ HashMap<String, Element> exportMapping =
+ _computeExportMapping(library, new HashSet<LibraryElement>());
+ library.exportNamespace = new Namespace(exportMapping);
Brian Wilkerson 2016/03/20 21:26:29 Shouldn't we just return 'exportMapping' at this p
scheglov 2016/03/20 22:16:47 Fixed. Thanks!
+ }
+ }
+ return _computeExportMapping(library, new HashSet<LibraryElement>());
+ }
+
/**
* Create a mapping table representing the export namespace of the given library.
*
@@ -6768,7 +6780,7 @@ class NamespaceBuilder {
* be added by another library
* @return the mapping table that was created
*/
- HashMap<String, Element> _createExportMapping(
+ HashMap<String, Element> _computeExportMapping(
LibraryElement library, HashSet<LibraryElement> visitedElements) {
visitedElements.add(library);
try {
@@ -6782,7 +6794,7 @@ class NamespaceBuilder {
// valid library.
//
HashMap<String, Element> exportedNames =
- _createExportMapping(exportedLibrary, visitedElements);
+ _computeExportMapping(exportedLibrary, visitedElements);
exportedNames = _applyCombinators(exportedNames, element.combinators);
definedNames.addAll(exportedNames);
}

Powered by Google App Engine
This is Rietveld 408576698