Replaced StringBuilder by simple char array in "hotspot" method

This commit is contained in:
Roland Praml authored and Roel Spilker committed 2018-07-20 09:41:24 +02:00
1 parent ff739d6d5a
commit be1cfd2f59
1 file changed
+6 -5
@@ -116,23 +116,24 @@ public class ClassFileMetaData {
int end = pos + size;
// the resulting string might be smaller
StringBuilder result = new StringBuilder(size);
char[] result = new char[size];
int length = 0;
while (pos < end) {
int first = (byteCode[pos++] & 0xFF);
if (first < 0x80) {
result.append((char)first);
result[length++] = (char)first;
} else if ((first & 0xE0) == 0xC0) {
int x = (first & 0x1F) << 6;
int y = (byteCode[pos++] & 0x3F);
result.append((char)(x | y));
result[length++] = (char)(x | y);
} else {
int x = (first & 0x0F) << 12;
int y = (byteCode[pos++] & 0x3F) << 6;
int z = (byteCode[pos++] & 0x3F);
result.append((char)(x | y | z));
result[length++] = (char)(x | y | z);
}
}
return result.toString();
return new String(result, 0, length);
}
/**