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

Unified Diff: pkg/polymer/lib/src/build/script_compactor.dart

Issue 700733002: Track initializers already seen (fixes #21439) (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 1 month 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 | pkg/polymer/pubspec.yaml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/polymer/lib/src/build/script_compactor.dart
diff --git a/pkg/polymer/lib/src/build/script_compactor.dart b/pkg/polymer/lib/src/build/script_compactor.dart
index 20d805287fcc472d0d4c662559f97d5fdd5647fc..bd3b3d8da21d70716ff5503d1504900f90df40da 100644
--- a/pkg/polymer/lib/src/build/script_compactor.dart
+++ b/pkg/polymer/lib/src/build/script_compactor.dart
@@ -249,13 +249,15 @@ class _ScriptCompactor extends PolymerTransformer {
// Process all classes and top-level functions to include initializers,
// register custom elements, and include special fields and methods in
// custom element classes.
+ var functionsSeen = new Set<FunctionElement>();
+ var classesSeen = new Set<ClassElement>();
for (var id in entryLibraries) {
var lib = resolver.getLibrary(id);
- for (var fun in _visibleTopLevelMethodsOf(lib)) {
+ for (var fun in _visibleTopLevelMethodsOf(lib, functionsSeen)) {
_processFunction(fun, id);
}
- for (var cls in _visibleClassesOf(lib)) {
+ for (var cls in _visibleClassesOf(lib, classesSeen)) {
_processClass(cls, id, recorder);
}
}
@@ -807,28 +809,41 @@ class _ResolvedTypes {
/// Retrieves all classses that are visible if you were to import [lib]. This
/// includes exported classes from other libraries.
-List<ClassElement> _visibleClassesOf(LibraryElement lib) {
+List<ClassElement> _visibleClassesOf(LibraryElement lib,
+ Set<ClassElement> seen) {
var result = [];
- result.addAll(lib.units.expand((u) => u.types));
+ addAllNew(list) => list.forEach((e) {
+ if (!seen.contains(e)) result.add(e);
+ });
+ addAllNew(lib.units.expand((u) => u.types));
for (var e in lib.exports) {
- var exported = e.exportedLibrary.units.expand((u) => u.types).toList();
+ var exportedLibrary = e.exportedLibrary;
+ if (seen.contains(exportedLibrary)) continue;
+ var exported = exportedLibrary.units.expand((u) => u.types).toList();
_filter(exported, e.combinators);
- result.addAll(exported);
+ addAllNew(exported);
}
+ seen.addAll(result);
return result;
}
/// Retrieves all top-level methods that are visible if you were to import
/// [lib]. This includes exported methods from other libraries too.
-List<FunctionElement> _visibleTopLevelMethodsOf(LibraryElement lib) {
+List<FunctionElement> _visibleTopLevelMethodsOf(
+ LibraryElement lib, Set<FunctionElement> seen) {
var result = [];
- result.addAll(lib.units.expand((u) => u.functions));
+ addAllNew(list) => list.forEach((e) {
jakemac 2014/11/04 17:45:54 I would probably break this out into a function th
Siggi Cherem (dart-lang) 2014/11/04 17:55:08 good point - this made me realize that I could jus
+ if (!seen.contains(e)) result.add(e);
+ });
+ addAllNew(lib.units.expand((u) => u.functions));
for (var e in lib.exports) {
- var exported = e.exportedLibrary.units
- .expand((u) => u.functions).toList();
+ var exportedLibrary = e.exportedLibrary;
+ if (seen.contains(exportedLibrary)) continue;
+ var exported = exportedLibrary.units.expand((u) => u.functions).toList();
_filter(exported, e.combinators);
- result.addAll(exported);
+ addAllNew(exported);
}
+ seen.addAll(result);
return result;
}
« no previous file with comments | « no previous file | pkg/polymer/pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698