Use a period in disambiguated loadIds

This allows the original loadId to be determined when the original ends in a digit.

Change-Id: I37231229c538c66fd54c79dffbfded3aa9e3973b
Reviewed-on: https://dart-review.googlesource.com/36490
Commit-Queue: Stephen Adams <sra@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
This commit is contained in:
Stephen Adams 2018-02-06 21:46:53 +00:00 committed by commit-bot@chromium.org
parent 762b336f2b
commit 079a4b08f5
2 changed files with 6 additions and 4 deletions

View file

@ -515,8 +515,9 @@ abstract class DeferredLoadTask extends CompilerTask {
String result = computeImportDeferName(import, compiler);
assert(result != null);
// Note: tools that process the json file to build multi-part initial load
// bundles depend on the fact that makeUnique appends only digits.
_importDeferName[import] = makeUnique(result, usedImportNames);
// bundles depend on the fact that makeUnique appends only digits, or a
// period followed by digits.
_importDeferName[import] = makeUnique(result, usedImportNames, '.');
}
// Sort the output units in descending order of the number of imports they

View file

@ -245,13 +245,14 @@ int longestCommonPrefixLength(List a, List b) {
/// the smallest number that makes it not appear in [usedNames].
///
/// Adds the result to [usedNames].
String makeUnique(String suggestedName, Set<String> usedNames) {
String makeUnique(String suggestedName, Set<String> usedNames,
[String separator = '']) {
String result = suggestedName;
if (usedNames.contains(suggestedName)) {
int counter = 0;
while (usedNames.contains(result)) {
counter++;
result = "$suggestedName$counter";
result = "$suggestedName$separator$counter";
}
}
usedNames.add(result);