Index: sdk/lib/_internal/compiler/implementation/deferred_load.dart |
diff --git a/sdk/lib/_internal/compiler/implementation/deferred_load.dart b/sdk/lib/_internal/compiler/implementation/deferred_load.dart |
index ddf061c62e25b7dd1e5d0a46b67a12a20115803f..dffcbb9ecb23f56e47220ad002727de58ab19966 100644 |
--- a/sdk/lib/_internal/compiler/implementation/deferred_load.dart |
+++ b/sdk/lib/_internal/compiler/implementation/deferred_load.dart |
@@ -57,6 +57,8 @@ import 'resolution/resolution.dart' show |
TreeElements, |
AnalyzableElementX; |
+import "dart:math" show min; |
+ |
/// A "hunk" of the program that will be loaded whenever one of its [imports] |
/// are loaded. |
/// |
@@ -564,9 +566,21 @@ class DeferredLoadTask extends CompilerTask { |
void computeOutputUnitName(OutputUnit outputUnit) { |
if (generatedNames[outputUnit] != null) return; |
- String suggestedName = outputUnit.imports.map((import) { |
+ Iterable<String> importNames = outputUnit.imports.map((import) { |
return importDeferName[import]; |
- }).join('_'); |
+ }); |
+ String suggestedName = importNames.join('_'); |
Alan Knight
2014/07/07 20:08:07
Is this going to run into potential problems with
sigurdm
2014/07/08 07:19:58
We take care of the uniqueness a few lines further
|
+ // Avoid the name getting too long. |
+ // Try to abbreviate the prefix-names |
+ if (suggestedName.length > 15) { |
+ suggestedName = importNames.map((name) { |
+ return name.substring(0, min(2, name.length)); |
+ }).join('_'); |
+ } |
+ // If this is still too long, truncate the whole name. |
+ if (suggestedName.length > 15) { |
+ suggestedName = suggestedName.substring(0, 15); |
+ } |
outputUnit.name = makeUnique(suggestedName, usedOutputUnitNames); |
generatedNames[outputUnit] = outputUnit.name; |
} |