提交 88ad5a36 authored 作者: Noel Grandin's avatar Noel Grandin

don't use substring when doing StringBuffer#append

reduces garbage
上级 d36834f9
...@@ -2066,7 +2066,7 @@ public class Function extends Expression implements FunctionCall { ...@@ -2066,7 +2066,7 @@ public class Function extends Expression implements FunctionCall {
if (buff == null) { if (buff == null) {
buff = new StringBuilder(size); buff = new StringBuilder(size);
if (i > 0) { if (i > 0) {
buff.append(original.substring(0, i)); buff.append(original, 0, i);
} }
} }
if (index < replaceSize) { if (index < replaceSize) {
......
...@@ -551,7 +551,7 @@ public class Csv implements SimpleRowSource { ...@@ -551,7 +551,7 @@ public class Csv implements SimpleRowSource {
buff.append(chars[idx + 1]); buff.append(chars[idx + 1]);
start = idx + 2; start = idx + 2;
} }
buff.append(s.substring(start)); buff.append(s, start, s.length());
return buff.toString(); return buff.toString();
} }
......
...@@ -583,7 +583,7 @@ public class StringUtils { ...@@ -583,7 +583,7 @@ public class StringUtils {
} }
int n = s.indexOf('\n', i); int n = s.indexOf('\n', i);
n = n < 0 ? s.length() : n + 1; n = n < 0 ? s.length() : n + 1;
buff.append(s.substring(i, n)); buff.append(s, i, n);
i = n; i = n;
} }
if (newline && !s.endsWith("\n")) { if (newline && !s.endsWith("\n")) {
......
...@@ -213,7 +213,7 @@ public class TestScript extends TestBase { ...@@ -213,7 +213,7 @@ public class TestScript extends TestBase {
// do nothing // do nothing
} else if (sql.endsWith(";")) { } else if (sql.endsWith(";")) {
write(sql); write(sql);
buff.append(sql.substring(0, sql.length() - 1)); buff.append(sql, 0, sql.length() - 1);
sql = buff.toString(); sql = buff.toString();
buff = new StringBuilder(); buff = new StringBuilder();
process(sql); process(sql);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论