提交 73f2d696 authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Do not allocate 4096-byte strings, trim data before allocation

上级 15b90dfb
...@@ -681,7 +681,14 @@ public final class DataUtils { ...@@ -681,7 +681,14 @@ public final class DataUtils {
* @throws IllegalStateException if parsing failed * @throws IllegalStateException if parsing failed
*/ */
public static HashMap<String, String> parseChecksummedMap(byte[] bytes) { public static HashMap<String, String> parseChecksummedMap(byte[] bytes) {
String s = new String(bytes, StandardCharsets.ISO_8859_1).trim(); int start = 0, end = bytes.length;
while (start < end && bytes[start] <= ' ') {
start++;
}
while (start < end && bytes[end - 1] <= ' ') {
end--;
}
String s = new String(bytes, start, end - start, StandardCharsets.ISO_8859_1);
HashMap<String, String> map = New.hashMap(); HashMap<String, String> map = New.hashMap();
StringBuilder buff = new StringBuilder(); StringBuilder buff = new StringBuilder();
for (int i = 0, size = s.length(); i < size;) { for (int i = 0, size = s.length(); i < size;) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论