| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 part of dart_backend; | 5 part of dart_backend; |
| 6 | 6 |
| 7 Function get _compareNodes => | 7 Function get _compareNodes => |
| 8 compareBy((n) => n.getBeginToken().charOffset); | 8 compareBy((n) => n.getBeginToken().charOffset); |
| 9 | 9 |
| 10 typedef String _Renamer(Renamable renamable); | 10 typedef String _Renamer(Renamable renamable); |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 // the same identifier. So the top-used local variables in all functions | 183 // the same identifier. So the top-used local variables in all functions |
| 184 // will be renamed first and will all share the same new identifier. | 184 // will be renamed first and will all share the same new identifier. |
| 185 List<Set<Node>> allSortedLocals = new List<Set<Node>>(); | 185 List<Set<Node>> allSortedLocals = new List<Set<Node>>(); |
| 186 for (var functionScope in placeholderCollector.functionScopes.values) { | 186 for (var functionScope in placeholderCollector.functionScopes.values) { |
| 187 // Add current sorted local identifiers to the whole sorted list | 187 // Add current sorted local identifiers to the whole sorted list |
| 188 // of all local identifiers for all functions. | 188 // of all local identifiers for all functions. |
| 189 List<LocalPlaceholder> currentSortedPlaceholders = | 189 List<LocalPlaceholder> currentSortedPlaceholders = |
| 190 sorted(functionScope.localPlaceholders, | 190 sorted(functionScope.localPlaceholders, |
| 191 compareBy((LocalPlaceholder ph) => -ph.nodes.length)); | 191 compareBy((LocalPlaceholder ph) => -ph.nodes.length)); |
| 192 List<Set<Node>> currentSortedNodes = | 192 List<Set<Node>> currentSortedNodes = |
| 193 currentSortedPlaceholders.mappedBy((ph) => ph.nodes); | 193 currentSortedPlaceholders.mappedBy((ph) => ph.nodes).toList(); |
| 194 // Make room in all sorted locals list for new stuff. | 194 // Make room in all sorted locals list for new stuff. |
| 195 while (currentSortedNodes.length > allSortedLocals.length) { | 195 while (currentSortedNodes.length > allSortedLocals.length) { |
| 196 allSortedLocals.add(new Set<Node>()); | 196 allSortedLocals.add(new Set<Node>()); |
| 197 } | 197 } |
| 198 for (int i = 0; i < currentSortedNodes.length; i++) { | 198 for (int i = 0; i < currentSortedNodes.length; i++) { |
| 199 allSortedLocals[i].addAll(currentSortedNodes[i]); | 199 allSortedLocals[i].addAll(currentSortedNodes[i]); |
| 200 } | 200 } |
| 201 } | 201 } |
| 202 | 202 |
| 203 // Rename elements, members and locals together based on their usage count, | 203 // Rename elements, members and locals together based on their usage count, |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 349 index ~/= firstCharAlphabet.length; | 349 index ~/= firstCharAlphabet.length; |
| 350 int length = otherCharsAlphabet.length; | 350 int length = otherCharsAlphabet.length; |
| 351 while (index >= length) { | 351 while (index >= length) { |
| 352 resultBuilder.add(otherCharsAlphabet[index % length]); | 352 resultBuilder.add(otherCharsAlphabet[index % length]); |
| 353 index ~/= length; | 353 index ~/= length; |
| 354 } | 354 } |
| 355 resultBuilder.add(otherCharsAlphabet[index]); | 355 resultBuilder.add(otherCharsAlphabet[index]); |
| 356 return resultBuilder.toString(); | 356 return resultBuilder.toString(); |
| 357 } | 357 } |
| 358 } | 358 } |
| OLD | NEW |