LUCENE-5207: Remove stupidity... :(

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/branches/lucene5207@1522888 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Uwe Schindler 2013-09-13 12:06:26 +00:00
parent d586a56a3b
commit fc2d83400b
1 changed files with 4 additions and 4 deletions

View File

@ -116,6 +116,8 @@ public class JavascriptCompiler {
}
}
private static final int MAX_CLASS_NAME_LENGTH = 1024;
private static final String EXPRESSION_CLASS_PREFIX = JavascriptCompiler.class.getPackage().getName() + ".Expr_";
private static final String COMPILED_EXPRESSION_INTERNAL = Type.getInternalName(Expression.class);
@ -184,9 +186,9 @@ public class JavascriptCompiler {
}
private String createClassName(String sourceText) {
final StringBuilder sb = new StringBuilder(sourceText.length() / 2);
final StringBuilder sb = new StringBuilder(Math.min(sourceText.length() / 2, MAX_CLASS_NAME_LENGTH));
boolean wasIdentifierPart = true;
for (int i = 0, c = sourceText.length(); i < c; i++) {
for (int i = 0, c = sourceText.length(); i < c && sb.length() < MAX_CLASS_NAME_LENGTH; i++) {
final char ch = sourceText.charAt(i);
if (Character.isJavaIdentifierPart(ch)) {
sb.append(ch);
@ -196,8 +198,6 @@ public class JavascriptCompiler {
wasIdentifierPart = false;
}
}
// limit maximum length, theoretically 65536 is allowed in constant pool (in UTF-8 format).
if (sb.length() > 1204) sb.setLength(1024);
// remove trailing underscores
for (int i = sb.length() - 1; i >= 0; i--) {
if (sb.charAt(i) == '_') {