Skip to content

Commit

Permalink
局部变量线程安全,优先使用StringBuilder替换StringBuffer (#4472)
Browse files Browse the repository at this point in the history
Co-authored-by: 夏亮 <[email protected]>
  • Loading branch information
HumanPassenger and xialiangnewerabccom authored Nov 16, 2022
1 parent 571fa0d commit 10ff148
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,11 @@ public int compare(String str1, String str2) {
private List<String> completionPattern(List<String> patterns) {
List<String> result = new ArrayList<>();
for (String pattern : patterns) {
StringBuffer stringBuffer = new StringBuffer();
stringBuffer.append("^");
stringBuffer.append(pattern);
stringBuffer.append("$");
result.add(stringBuffer.toString());
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("^");
stringBuilder.append(pattern);
stringBuilder.append("$");
result.add(stringBuilder.toString());
}
return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,11 @@ public int compare(String str1, String str2) {
private List<String> completionPattern(List<String> patterns) {
List<String> result = new ArrayList<>();
for (String pattern : patterns) {
StringBuffer stringBuffer = new StringBuffer();
stringBuffer.append("^");
stringBuffer.append(pattern);
stringBuffer.append("$");
result.add(stringBuffer.toString());
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("^");
stringBuilder.append(pattern);
stringBuilder.append("$");
result.add(stringBuilder.toString());
}
return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public DdlResult clone() {
@Override
public String toString() {
DdlResult ddlResult = this;
StringBuffer sb = new StringBuffer();
StringBuilder sb = new StringBuilder();
do {
sb.append(String.format("DdlResult [schemaName=%s , tableName=%s , oriSchemaName=%s , oriTableName=%s , type=%s ];",
ddlResult.schemaName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public boolean rollback(EntryPosition position) {
public Map<String, String> snapshot() {
Map<String, String> schemaDdls = new HashMap<>();
for (Schema schema : repository.getSchemas()) {
StringBuffer data = new StringBuffer(4 * 1024);
StringBuilder data = new StringBuilder(4 * 1024);
for (String table : schema.showTables()) {
SchemaObject schemaObject = schema.findTable(table);
schemaObject.getStatement().output(data);
Expand Down

0 comments on commit 10ff148

Please sign in to comment.