| Index: sdk/lib/_internal/compiler/implementation/util/util.dart
|
| diff --git a/sdk/lib/_internal/compiler/implementation/util/util.dart b/sdk/lib/_internal/compiler/implementation/util/util.dart
|
| index bf18c10b569463f33abadb53a221eb3b150b8ca8..7dbc572ec123728d5b3e082b40e5d7d46696f9a4 100644
|
| --- a/sdk/lib/_internal/compiler/implementation/util/util.dart
|
| +++ b/sdk/lib/_internal/compiler/implementation/util/util.dart
|
| @@ -194,3 +194,20 @@ int longestCommonPrefixLength(List a, List b) {
|
| }
|
| return index;
|
| }
|
| +
|
| +/// Returns [suggestedName] if it is not in [usedNames]. Otherwise concatenates
|
| +/// the smallest number that makes it not appear in [usedNames].
|
| +///
|
| +/// Adds the result to [usedNames].
|
| +String makeUnique(String suggestedName, Set<String> usedNames) {
|
| + String result = suggestedName;
|
| + if (usedNames.contains(suggestedName)) {
|
| + int counter = 0;
|
| + while (usedNames.contains(result)) {
|
| + counter++;
|
| + result = "$suggestedName$counter";
|
| + }
|
| + }
|
| + usedNames.add(result);
|
| + return result;
|
| +}
|
|
|