Commit 6fc7c7a4 authored by Ahmed Ashour's avatar Ahmed Ashour Committed by skylot

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

parent 98dbd488
...@@ -16,11 +16,13 @@ public class StringUtils { ...@@ -16,11 +16,13 @@ public class StringUtils {
return "\"\""; return "\"\"";
} }
StringBuilder res = new StringBuilder(); StringBuilder res = new StringBuilder();
res.append('"');
for (int i = 0; i < len; i++) { for (int i = 0; i < len; i++) {
int c = str.charAt(i) & 0xFFFF; int c = str.charAt(i) & 0xFFFF;
processChar(c, res); processChar(c, res);
} }
return '"' + res.toString() + '"'; res.append('"');
return res.toString();
} }
public String unescapeChar(char ch) { public String unescapeChar(char ch) {
...@@ -28,8 +30,10 @@ public class StringUtils { ...@@ -28,8 +30,10 @@ public class StringUtils {
return "'\\\''"; return "'\\\''";
} }
StringBuilder res = new StringBuilder(); StringBuilder res = new StringBuilder();
res.append('\'');
processChar(ch, res); processChar(ch, res);
return '\'' + res.toString() + '\''; res.append('\'');
return res.toString();
} }
private void processChar(int c, StringBuilder res) { private void processChar(int c, StringBuilder res) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment