Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(466)

Unified Diff: lib/compiler/implementation/dart_backend/renamer.dart

Issue 10861016: Introduce renameNodes helper to factor out common pattern. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/compiler/implementation/dart_backend/renamer.dart
diff --git a/lib/compiler/implementation/dart_backend/renamer.dart b/lib/compiler/implementation/dart_backend/renamer.dart
index 6cb47f76933ce788de7d7a7ba4b5556e60b75b84..1f5ba60b47e63263dbe541bf90591b3191061750 100644
--- a/lib/compiler/implementation/dart_backend/renamer.dart
+++ b/lib/compiler/implementation/dart_backend/renamer.dart
@@ -50,35 +50,32 @@ void renamePlaceholders(
() => generateUniqueName(originalName));
}
- placeholderCollector.nullNodes.forEach((Node node) {
- renames[node] = '';
- });
- placeholderCollector.unresolvedNodes.forEach((Node node) {
- renames[node] = generateUniqueName('Unresolved');
- });
+ renameNodes(Collection<Node> nodes, renamer) {
+ for (Node node in nodes) {
+ renames[node] = renamer(node);
+ }
+ }
+
+ renameNodes(placeholderCollector.nullNodes, (_) => '');
Roman 2012/08/21 08:02:44 did you use '_' instead of 'node' to save 3 chars
Anton Muhin 2012/08/21 09:11:10 That's the common idiom to mark unused argument.
+ renameNodes(placeholderCollector.unresolvedNodes,
+ (_) => generateUniqueName('Unresolved'));
placeholderCollector.elementNodes.forEach(
(Element element, Set<Node> nodes) {
String renamedElement = renameElement(element);
- nodes.forEach((Node node) {
- renames[node] = renamedElement;
- });
+ renameNodes(nodes, (_) => renamedElement);
});
placeholderCollector.localPlaceholders.forEach(
(FunctionElement element, Set<LocalPlaceholder> localPlaceholders) {
// TODO(smok): Check for conflicts with class fields and take usages
// into account.
localPlaceholders.forEach((LocalPlaceholder placeholder) {
- placeholder.nodes.forEach((Node node) {
- renames[node] = placeholder.identifier;
- });
+ renameNodes(placeholder.nodes, (_) => placeholder.identifier);
});
});
placeholderCollector.privateNodes.forEach(
(LibraryElement library, Set<Identifier> nodes) {
- nodes.forEach((Identifier node) {
- renames[node] =
- renamePrivateIdentifier(library, node.source.slowToString());
- });
+ renameNodes(nodes, (node) =>
+ renamePrivateIdentifier(library, node.source.slowToString()));
});
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698