| Index: sdk/lib/_internal/compiler/implementation/dart_backend/renamer.dart
|
| diff --git a/sdk/lib/_internal/compiler/implementation/dart_backend/renamer.dart b/sdk/lib/_internal/compiler/implementation/dart_backend/renamer.dart
|
| index 73480bf01e2e008b890b53c465dea118233272b6..cb7c4a771d8501200110b39ec591550359b972fe 100644
|
| --- a/sdk/lib/_internal/compiler/implementation/dart_backend/renamer.dart
|
| +++ b/sdk/lib/_internal/compiler/implementation/dart_backend/renamer.dart
|
| @@ -180,33 +180,24 @@ void renamePlaceholders(
|
| renameElement = makeElementRenamer(rename, generateUniqueName);
|
|
|
| List<Set<Node>> allLocals = new List<Set<Node>>();
|
| - // If we are using the mirror_helper library we need all names to be
|
| - // globally unique.
|
| - if (uniqueGlobalNaming) {
|
| - //TODO(zarah): Change this so that local variables don't get unique names.
|
| - for (var functionScope in placeholderCollector.functionScopes.values) {
|
| - functionScope.localPlaceholders.forEach(
|
| - (ph) => allLocals.add(ph.nodes.toSet()));
|
| +
|
| + // Build a list sorted by usage of local nodes that will be renamed to
|
| + // the same identifier. So the top-used local variables in all functions
|
| + // will be renamed first and will all share the same new identifier.
|
| + for (var functionScope in placeholderCollector.functionScopes.values) {
|
| + // Add current sorted local identifiers to the whole sorted list
|
| + // of all local identifiers for all functions.
|
| + List<LocalPlaceholder> currentSortedPlaceholders =
|
| + sorted(functionScope.localPlaceholders,
|
| + compareBy((LocalPlaceholder ph) => -ph.nodes.length));
|
| + List<Set<Node>> currentSortedNodes =
|
| + currentSortedPlaceholders.map((ph) => ph.nodes).toList();
|
| + // Make room in all sorted locals list for new stuff.
|
| + while (currentSortedNodes.length > allLocals.length) {
|
| + allLocals.add(new Set<Node>());
|
| }
|
| - } else {
|
| - // Build a sorted (by usage) list of local nodes that will be renamed to
|
| - // the same identifier. So the top-used local variables in all functions
|
| - // will be renamed first and will all share the same new identifier.
|
| - for (var functionScope in placeholderCollector.functionScopes.values) {
|
| - // Add current sorted local identifiers to the whole sorted list
|
| - // of all local identifiers for all functions.
|
| - List<LocalPlaceholder> currentSortedPlaceholders =
|
| - sorted(functionScope.localPlaceholders,
|
| - compareBy((LocalPlaceholder ph) => -ph.nodes.length));
|
| - List<Set<Node>> currentSortedNodes =
|
| - currentSortedPlaceholders.map((ph) => ph.nodes).toList();
|
| - // Make room in all sorted locals list for new stuff.
|
| - while (currentSortedNodes.length > allLocals.length) {
|
| - allLocals.add(new Set<Node>());
|
| - }
|
| - for (int i = 0; i < currentSortedNodes.length; i++) {
|
| - allLocals[i].addAll(currentSortedNodes[i]);
|
| - }
|
| + for (int i = 0; i < currentSortedNodes.length; i++) {
|
| + allLocals[i].addAll(currentSortedNodes[i]);
|
| }
|
| }
|
|
|
|
|