Use StringBuilder.append(char) where possible

To slightly improve performance, this commit switches to
StringBuilder.append(char) instead of StringBuilder.append(String)
whenever we append a single character to a StringBuilder.

Closes gh-27098
This commit is contained in:
Sam Brannen
2021-06-24 18:53:51 +02:00
parent ddbb7c1b5b
commit a2ef6badc4
74 changed files with 232 additions and 220 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -646,13 +646,13 @@ public class CallMetaDataContext {
}
if (StringUtils.hasLength(catalogNameToUse)) {
callString.append(catalogNameToUse).append(".");
callString.append(catalogNameToUse).append('.');
}
if (StringUtils.hasLength(schemaNameToUse)) {
callString.append(schemaNameToUse).append(".");
callString.append(schemaNameToUse).append('.');
}
callString.append(this.metaDataProvider.procedureNameToUse(getProcedureName()));
callString.append("(");
callString.append('(');
for (SqlParameter parameter : this.callParameters) {
if (!parameter.isResultsParameter()) {

View File

@@ -280,7 +280,7 @@ public class TableMetaDataContext {
insertStatement.append("INSERT INTO ");
if (getSchemaName() != null) {
insertStatement.append(getSchemaName());
insertStatement.append(".");
insertStatement.append('.');
}
insertStatement.append(getTableName());
insertStatement.append(" (");
@@ -313,7 +313,7 @@ public class TableMetaDataContext {
}
String params = String.join(", ", Collections.nCopies(columnCount, "?"));
insertStatement.append(params);
insertStatement.append(")");
insertStatement.append(')');
return insertStatement.toString();
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -186,10 +186,10 @@ public class TransactionAwareDataSourceProxy extends DelegatingDataSource {
// Allow for differentiating between the proxy and the raw Connection.
StringBuilder sb = new StringBuilder("Transaction-aware proxy for target Connection ");
if (this.target != null) {
sb.append("[").append(this.target.toString()).append("]");
sb.append('[').append(this.target.toString()).append(']');
}
else {
sb.append(" from DataSource [").append(this.targetDataSource).append("]");
sb.append(" from DataSource [").append(this.targetDataSource).append(']');
}
return sb.toString();
case "close":

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -152,7 +152,7 @@ public abstract class AbstractIdentityColumnMaxValueIncrementer extends Abstract
for (int i = 0; i < values.length - 1; i++) {
sb.append(", ").append(values[i]);
}
sb.append(")");
sb.append(')');
}
else {
long maxValue = values[values.length - 1];