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

Unified Diff: pkg/compiler/lib/src/js_backend/minify_namer.dart

Issue 1153363003: dart2js: Avoid common prefix for frequent bad names. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 7 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: pkg/compiler/lib/src/js_backend/minify_namer.dart
diff --git a/pkg/compiler/lib/src/js_backend/minify_namer.dart b/pkg/compiler/lib/src/js_backend/minify_namer.dart
index 45a10eb2d81059c9f5ef5f55106848b2165c0622..c2a9f4599a73286757225abba39a74aadeaba943 100644
--- a/pkg/compiler/lib/src/js_backend/minify_namer.dart
+++ b/pkg/compiler/lib/src/js_backend/minify_namer.dart
@@ -209,10 +209,17 @@ class MinifyNamer extends Namer {
return h;
}
+ /// Remember bad hashes to avoid using a the same character with long numbers
+ /// for frequent hashes. For example, `closure` is a very common name.
+ Map<int, int> _badNames = new Map<int, int>();
+
/// If we can't find a hash based name in the three-letter space, then base
/// the name on a letter and a counter.
String _badName(int hash, Set<String> usedNames) {
- String startLetter = new String.fromCharCodes([_letterNumber(hash)]);
+ int count = _badNames.putIfAbsent(hash, () => 0);
+ String startLetter =
+ new String.fromCharCodes([_letterNumber(hash + count)]);
+ _badNames[hash] = count + 1;
String name;
int i = 0;
do {
« 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