Commit b19dcb13 authored by andrey.onufreyko's avatar andrey.onufreyko Committed by Phillip Webb

Replace string arguments with char

Optimize method calls by replacing single character String arguments
with char.

Closes gh-11680
parent 2735f57b
......@@ -71,7 +71,7 @@ public class Token {
}
public byte[] getContent() {
return this.encoded.substring(0, this.encoded.lastIndexOf(".")).getBytes();
return this.encoded.substring(0, this.encoded.lastIndexOf('.')).getBytes();
}
public byte[] getSignature() {
......
......@@ -94,7 +94,7 @@ public class AuditEvent implements Serializable {
private static Map<String, Object> convert(String[] data) {
Map<String, Object> result = new HashMap<>();
for (String entry : data) {
int index = entry.indexOf("=");
int index = entry.indexOf('=');
if (index != -1) {
result.put(entry.substring(0, index), entry.substring(index + 1));
}
......
......@@ -891,7 +891,7 @@ public class RabbitProperties {
}
private String parseVirtualHost(String input) {
int hostIndex = input.indexOf("/");
int hostIndex = input.indexOf('/');
if (hostIndex >= 0) {
this.virtualHost = input.substring(hostIndex + 1);
if (this.virtualHost.isEmpty()) {
......
......@@ -132,7 +132,7 @@ abstract class RedisConnectionConfiguration {
String password = null;
if (uri.getUserInfo() != null) {
password = uri.getUserInfo();
int index = password.lastIndexOf(":");
int index = password.lastIndexOf(':');
if (index >= 0) {
password = password.substring(index + 1);
}
......
......@@ -33,8 +33,8 @@ class DataSourceBeanCreationFailureAnalyzer
protected FailureAnalysis analyze(Throwable rootFailure,
DataSourceBeanCreationException cause) {
String message = cause.getMessage();
String description = message.substring(0, message.indexOf(".")).trim();
String action = message.substring(message.indexOf(".") + 1).trim();
String description = message.substring(0, message.indexOf('.')).trim();
String action = message.substring(message.indexOf('.') + 1).trim();
return new FailureAnalysis(description, action, cause);
}
......
......@@ -292,7 +292,7 @@ public class ServerProperties {
public String getServletPrefix() {
String result = this.path;
int index = result.indexOf("*");
int index = result.indexOf('*');
if (index != -1) {
result = result.substring(0, index);
}
......
......@@ -251,7 +251,7 @@ class InitializrService {
int start = value.indexOf(FILENAME_HEADER_PREFIX);
if (start != -1) {
value = value.substring(start + FILENAME_HEADER_PREFIX.length());
int end = value.indexOf("\"");
int end = value.indexOf('\"');
if (end != -1) {
return value.substring(0, end);
}
......
......@@ -48,7 +48,7 @@ class RemoteUrlPropertyExtractor
ConfigurableEnvironment environment = event.getEnvironment();
String url = cleanRemoteUrl(environment.getProperty(NON_OPTION_ARGS));
Assert.state(StringUtils.hasLength(url), "No remote URL specified");
Assert.state(url.indexOf(",") == -1, "Multiple URLs specified");
Assert.state(url.indexOf(',') == -1, "Multiple URLs specified");
try {
new URI(url);
}
......
......@@ -78,7 +78,7 @@ final class SpringBootConfigurationFinder {
}
private String getParentPackage(String sourcePackage) {
int lastDot = sourcePackage.lastIndexOf(".");
int lastDot = sourcePackage.lastIndexOf('.');
return (lastDot == -1 ? "" : sourcePackage.substring(0, lastDot));
}
......
......@@ -91,8 +91,8 @@ public abstract class EnvironmentTestUtils {
}
private static int getSeparatorIndex(String pair) {
int colonIndex = pair.indexOf(":");
int equalIndex = pair.indexOf("=");
int colonIndex = pair.indexOf(':');
int equalIndex = pair.indexOf('=');
if (colonIndex == -1) {
return equalIndex;
}
......
......@@ -267,8 +267,8 @@ public final class TestPropertyValues {
}
private static int getSeparatorIndex(String pair) {
int colonIndex = pair.indexOf(":");
int equalIndex = pair.indexOf("=");
int colonIndex = pair.indexOf(':');
int equalIndex = pair.indexOf('=');
if (colonIndex == -1) {
return equalIndex;
}
......
......@@ -30,7 +30,7 @@ class DescriptionExtractor {
if (description == null) {
return null;
}
int dot = description.indexOf(".");
int dot = description.indexOf('.');
if (dot != -1) {
BreakIterator breakIterator = BreakIterator.getSentenceInstance(Locale.US);
breakIterator.setText(description);
......
......@@ -176,7 +176,7 @@ public class JavaCompilerFieldValuesParser implements FieldValuesParser {
Object instance = expression.getInstance();
if (instance != null && instance.toString().startsWith(DURATION_OF)) {
String type = instance.toString();
type = type.substring(DURATION_OF.length(), type.indexOf("("));
type = type.substring(DURATION_OF.length(), type.indexOf('('));
String suffix = DURATION_SUFFIX.get(type);
return (suffix == null ? null : factoryValue + suffix);
}
......
......@@ -253,8 +253,8 @@ public class JarWriter implements LoaderClassesWriter, AutoCloseable {
else {
entry.setUnixMode(UnixStat.FILE_FLAG | UnixStat.DEFAULT_FILE_PERM);
}
if (parent.lastIndexOf("/") != -1) {
parent = parent.substring(0, parent.lastIndexOf("/") + 1);
if (parent.lastIndexOf('/') != -1) {
parent = parent.substring(0, parent.lastIndexOf('/') + 1);
if (!parent.isEmpty()) {
writeEntry(new JarArchiveEntry(parent), null);
}
......
......@@ -498,7 +498,7 @@ public class PropertiesLauncher extends Launcher {
// If home dir is same as parent archive, no need to add it twice.
return null;
}
int index = root.indexOf("!");
int index = root.indexOf('!');
if (index != -1) {
File file = new File(this.home, root.substring(0, index));
if (root.startsWith("jar:file:")) {
......
......@@ -112,8 +112,8 @@ public class JarFileArchive implements Archive {
private Archive getUnpackedNestedArchive(JarEntry jarEntry) throws IOException {
String name = jarEntry.getName();
if (name.lastIndexOf("/") != -1) {
name = name.substring(name.lastIndexOf("/") + 1);
if (name.lastIndexOf('/') != -1) {
name = name.substring(name.lastIndexOf('/') + 1);
}
File file = new File(getTempUnpackFolder(), name);
if (!file.exists() || file.length() != jarEntry.getSize()) {
......
......@@ -243,7 +243,7 @@ class BeanDefinitionLoader {
// a file list of the package content. We double check here that it's not
// actually a package.
String path = ((ClassPathResource) resource).getPath();
if (path.indexOf(".") == -1) {
if (path.indexOf('.') == -1) {
try {
return Package.getPackage(path) == null;
}
......
......@@ -93,7 +93,7 @@ class NoUniqueBeanDefinitionFailureAnalyzer
private String[] extractBeanNames(NoUniqueBeanDefinitionException cause) {
if (cause.getMessage().indexOf("but found") > -1) {
return StringUtils.commaDelimitedListToStringArray(cause.getMessage()
.substring(cause.getMessage().lastIndexOf(":") + 1).trim());
.substring(cause.getMessage().lastIndexOf(':') + 1).trim());
}
return null;
}
......
......@@ -69,7 +69,7 @@ class SpringPropertyAction extends Action {
if (value != null) {
return value;
}
int lastDot = source.lastIndexOf(".");
int lastDot = source.lastIndexOf('.');
if (lastDot > 0) {
String prefix = source.substring(0, lastDot + 1);
return this.environment.getProperty(prefix + source.substring(lastDot + 1),
......
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