Dart2js Avoid file-names of deferred .part-files from getting too long.

R=johnniwinther@google.com

Review URL: https://codereview.chromium.org//368193004

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@38000 260f80e4-7a28-3924-810f-c04153c831b5
This commit is contained in:
sigurdm@google.com 2014-07-04 07:51:47 +00:00
parent f75df05ddd
commit 9584fab35b

View file

@ -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];
});
String suggestedName = importNames.join('_');
// 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;
}