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

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

Issue 2771303002: Lazily initialize library elements. (Closed)
Patch Set: Created 3 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/compiler.dart
diff --git a/pkg/compiler/lib/src/compiler.dart b/pkg/compiler/lib/src/compiler.dart
index c2234858f0ab62c57a462a01e95ac13efaf2f569..bf91423f5b835d8912f3ba71b1a744abaa3eb910 100644
--- a/pkg/compiler/lib/src/compiler.dart
+++ b/pkg/compiler/lib/src/compiler.dart
@@ -384,7 +384,6 @@ abstract class Compiler {
/// libraries.
LoadedLibraries processLoadedLibraries(LoadedLibraries loadedLibraries) {
loadedLibraries.forEachLibrary((LibraryElement library) {
- _commonElements.registerCommonLibraries(library);
backend.setAnnotations(library);
});
@@ -1094,28 +1093,26 @@ class _CompilerCommonElements extends CommonElementsMixin {
final ElementEnvironment environment;
- LibraryElement coreLibrary;
- LibraryElement asyncLibrary;
- LibraryElement mirrorsLibrary;
- LibraryElement typedDataLibrary;
-
_CompilerCommonElements(this.environment, this.resolution, this.reporter);
@override
ResolutionDynamicType get dynamicType => const ResolutionDynamicType();
- void registerCommonLibraries(LibraryElement library) {
- Uri uri = library.canonicalUri;
- if (uri == Uris.dart_core) {
- coreLibrary = library;
- } else if (uri == Uris.dart_async) {
- asyncLibrary = library;
- } else if (uri == Uris.dart__native_typed_data) {
- typedDataLibrary = library;
- } else if (uri == Uris.dart_mirrors) {
- mirrorsLibrary = library;
- }
- }
+ LibraryEntity _coreLibrary;
+ LibraryEntity get coreLibrary =>
+ _coreLibrary ??= environment.lookupLibrary(Uris.dart_core);
+
+ LibraryEntity _typedDataLibrary;
+ LibraryEntity get typedDataLibrary => _typedDataLibrary ??=
+ environment.lookupLibrary(Uris.dart__native_typed_data);
+
+ LibraryEntity _mirrorsLibrary;
+ LibraryEntity get mirrorsLibrary =>
+ _mirrorsLibrary ??= environment.lookupLibrary(Uris.dart_mirrors);
+
+ LibraryEntity _asyncLibrary;
+ LibraryEntity get asyncLibrary =>
+ _asyncLibrary ??= environment.lookupLibrary(Uris.dart_async);
@override
MemberElement findLibraryMember(LibraryElement library, String name,
« 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