Chromium Code Reviews| 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..95b4daa053b3d666f16f803381bf41b5ef5c6890 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 sorted (by usage) list of local nodes that will be renamed to |
|
Johnni Winther
2013/08/28 07:04:23
"a sorted ... local nodes" -> "a list sorted by us
zarah
2013/08/28 10:18:14
Done.
|
| + // 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]); |
| } |
| } |