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

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

Issue 3000003002: call _getImports only once: on a large app this was about 5s extra. (Closed)
Patch Set: Created 3 years, 4 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/deferred_load.dart
diff --git a/pkg/compiler/lib/src/deferred_load.dart b/pkg/compiler/lib/src/deferred_load.dart
index fe77fd4bcad0d127e722fd624772f0631cb09b2a..43b3ebb684c052ad2622646b735946ec6cd39372 100644
--- a/pkg/compiler/lib/src/deferred_load.dart
+++ b/pkg/compiler/lib/src/deferred_load.dart
@@ -261,20 +261,6 @@ class DeferredLoadTask extends CompilerTask {
_constantToOutputUnit[constant] = _getCanonicalUnit(outputUnit);
}
- /// Answers whether [element] is explicitly deferred when referred to from
- /// [library].
- bool _isExplicitlyDeferred(Element element, LibraryElement library) {
- Iterable<ImportElement> imports = _getImports(element, library);
- // If the element is not imported explicitly, it is implicitly imported
- // not deferred.
- if (imports.isEmpty) return false;
- // An element could potentially be loaded by several imports. If all of them
- // is explicitly deferred, we say the element is explicitly deferred.
- // TODO(sigurdm): We might want to give a warning if the imports do not
- // agree.
- return imports.every((ImportElement import) => import.isDeferred);
- }
-
/// Returns every [ImportElement] that imports [element] into [library].
Iterable<ImportElement> _getImports(Element element, LibraryElement library) {
if (element.isClassMember) {
@@ -558,8 +544,19 @@ class DeferredLoadTask extends CompilerTask {
}
for (Element dependency in dependentElements) {
- if (_isExplicitlyDeferred(dependency, library)) {
- for (ImportElement deferredImport in _getImports(dependency, library)) {
+ Iterable<ImportElement> imports = _getImports(dependency, library);
sra1 2017/08/16 01:09:22 Presumably this is actually a List.
Siggi Cherem (dart-lang) 2017/08/16 01:18:20 Ack - I'm using the declared type for now. I feel
+ bool isExplicitlyDeferred =
sra1 2017/08/16 01:09:22 This can still be a function, just taking the iter
Siggi Cherem (dart-lang) 2017/08/16 01:18:20 Done. Moved it was it used to be, but made the lis
+ // If the element is not imported explicitly, it is implicitly
+ // imported not deferred.
+ !imports.isEmpty &&
+ // An element could potentially be loaded by several imports. If
+ // all of them are explicitly deferred, we say the element is
+ // explicitly deferred.
+ // TODO(sigurdm): We might want to give a warning if the imports
+ // do not agree.
+ imports.every((i) => i.isDeferred);
+ if (isExplicitlyDeferred) {
+ for (ImportElement deferredImport in imports) {
_mapDependencies(
element: dependency,
import: new _DeclaredDeferredImport(deferredImport));
« 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