提交 6fc7c7a4 编写于 作者: A Ahmed Ashour 提交者: skylot

chore: don't create unneeded StringBuilder (PR #541)

上级 98dbd488
......@@ -16,11 +16,13 @@ public class StringUtils {
return "\"\"";
}
StringBuilder res = new StringBuilder();
res.append('"');
for (int i = 0; i < len; i++) {
int c = str.charAt(i) & 0xFFFF;
processChar(c, res);
}
return '"' + res.toString() + '"';
res.append('"');
return res.toString();
}
public String unescapeChar(char ch) {
......@@ -28,8 +30,10 @@ public class StringUtils {
return "'\\\''";
}
StringBuilder res = new StringBuilder();
res.append('\'');
processChar(ch, res);
return '\'' + res.toString() + '\'';
res.append('\'');
return res.toString();
}
private void processChar(int c, StringBuilder res) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册