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

This commit is contained in:
Ahmed Ashour
2019-03-29 09:23:42 +01:00
committed by skylot
parent 98dbd48890
commit 6fc7c7a462
@@ -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) {