提交 e74aac10 authored 作者: Andrei Tokar's avatar Andrei Tokar

reduce garbage creation

上级 8e45edf0
......@@ -300,10 +300,10 @@ public class Trace {
if (!space) {
buff.append(' ');
}
buff.append("*/").
append(StringUtils.javaEncode(sql)).
append(StringUtils.javaEncode(params)).
append(';');
buff.append("*/");
StringUtils.javaEncode(sql, buff);
StringUtils.javaEncode(params, buff);
buff.append(';');
sql = buff.toString();
traceWriter.write(TraceSystem.INFO, module, sql, null);
}
......
......@@ -148,8 +148,13 @@ public class StringUtils {
* @return the Java representation
*/
public static String javaEncode(String s) {
StringBuilder buff = new StringBuilder(s.length());
javaEncode(s, buff);
return buff.toString();
}
public static void javaEncode(String s, StringBuilder buff) {
int length = s.length();
StringBuilder buff = new StringBuilder(length);
for (int i = 0; i < length; i++) {
char c = s.charAt(i);
switch (c) {
......@@ -202,7 +207,6 @@ public class StringUtils {
}
}
}
return buff.toString();
}
/**
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论