Enhancement Issue #2448, the first character of obfuscated identifiers can be chosen from a set of 54 safe characers, rather than just 32. Obfuscated Output code is reduced in size by 0.5-1.75%. Thanks to contributor andriasyan for the patch.
git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@5864 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/dev/core/src/com/google/gwt/dev/js/JsObfuscateNamer.java b/dev/core/src/com/google/gwt/dev/js/JsObfuscateNamer.java
index 989db83..7ff5f6b 100644
--- a/dev/core/src/com/google/gwt/dev/js/JsObfuscateNamer.java
+++ b/dev/core/src/com/google/gwt/dev/js/JsObfuscateNamer.java
@@ -36,9 +36,9 @@
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B',
'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
- 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '0', '1', '2', '3',
- '4', '5', '6', '7', '8', '9', '$', '_'};
-
+ 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '$', '_', '0', '1',
+ '2', '3', '4', '5', '6', '7', '8', '9'};
+
public static void exec(JsProgram program) {
new JsObfuscateNamer(program).execImpl();
}
@@ -77,13 +77,13 @@
}
private String makeObfuscatedIdent(int id) {
- // Use base-32 for the first character of the identifier,
+ // Use base-54 for the first character of the identifier,
// so that we don't use any numbers (which are illegal at
// the beginning of an identifier).
//
int i = 0;
- sIdentBuf[i++] = sBase64Chars[id & 0x1f];
- id >>= 5;
+ sIdentBuf[i++] = sBase64Chars[id % 54];
+ id /= 54;
// Use base-64 for the rest of the identifier.
//