mirror of
https://github.com/dart-lang/sdk
synced 2024-09-22 22:23:53 +00:00
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:
parent
f75df05ddd
commit
9584fab35b
|
@ -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('_');
|
||||
// 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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue