Skip to content

Commit

Permalink
optimize: optimize ColumnUtils.addEscape method performance (apache#2044
Browse files Browse the repository at this point in the history
)
  • Loading branch information
yangfuhai authored May 25, 2020
1 parent 7c38bb0 commit 7e04d2a
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,13 @@ private static String addEscape(String colName, String dbType, Escape escape) {
}
}

StringBuilder result = new StringBuilder(2 * (String.valueOf(escape.value).length()) + colName.length());
return result.append(escape.value).append(colName).append(escape.value).toString();
char[] buf = new char[colName.length() + 2];
buf[0] = escape.value;
buf[buf.length - 1] = escape.value;

colName.getChars(0,colName.length(),buf,1);

return new String(buf).intern();
}

private static boolean isMysqlSeries(String dbType) {
Expand Down

0 comments on commit 7e04d2a

Please sign in to comment.