Index: dart/lib/compiler/implementation/namer.dart |
diff --git a/dart/lib/compiler/implementation/namer.dart b/dart/lib/compiler/implementation/namer.dart |
index 09b1870464e19101b5d3d50c52ab01d2ca62fff9..7fbcdba5983edef451c685a5d824213a334368d2 100644 |
--- a/dart/lib/compiler/implementation/namer.dart |
+++ b/dart/lib/compiler/implementation/namer.dart |
@@ -106,21 +106,20 @@ class Namer { |
} |
String getFreshGlobalName(String proposedName) { |
- int usedCount = usedGlobals[proposedName]; |
- if (usedCount === null) { |
- // No element with this name has been used before. |
- usedGlobals[proposedName] = 1; |
- return proposedName; |
- } else { |
+ String name = proposedName; |
+ int count = usedGlobals[proposedName]; |
+ if (count !== null) { |
// Not the first time we see this name. Append a number to make it unique. |
- String name; |
do { |
- usedCount++; |
- name = '$proposedName$usedCount'; |
+ name = '$proposedName${count++}'; |
} while (usedGlobals[name] !== null); |
- usedGlobals[proposedName] = usedCount; |
- return name; |
+ // Record the count in case we see this name later. We |
+ // frequently see the name again, as all our closures use the |
floitsch
2012/06/20 11:04:06
frequently see names multiple times
ahe
2012/06/20 11:15:59
Done.
|
+ // same name for their class. |
+ usedGlobals[proposedName] = count; |
} |
+ usedGlobals[name] = 0; |
floitsch
2012/06/20 11:04:06
usedGlobals.putIfAbsent(name, () => 0) ?
ahe
2012/06/20 11:15:59
At this point we know that usedGlobals[name] === n
|
+ return name; |
} |
static final String LIBRARY_PREFIX = "lib"; |