Commit 4ae3691f authored by Johnny Lim's avatar Johnny Lim Committed by Stephane Nicoll

Avoid substring() invocation when the result is itself

Closes gh-10077
parent 8198b875
......@@ -73,7 +73,7 @@ public abstract class EnvironmentTestUtils {
Map<String, Object> map = getOrAdd(sources, name);
for (String pair : pairs) {
int index = getSeparatorIndex(pair);
String key = pair.substring(0, index > 0 ? index : pair.length());
String key = index > 0 ? pair.substring(0, index) : pair;
String value = index > 0 ? pair.substring(index + 1) : "";
map.put(key.trim(), value.trim());
}
......
......@@ -253,7 +253,7 @@ public final class TestPropertyValues {
public static Pair parse(String pair) {
int index = getSeparatorIndex(pair);
String key = pair.substring(0, index > 0 ? index : pair.length());
String key = index > 0 ? pair.substring(0, index) : pair;
String value = index > 0 ? pair.substring(index + 1) : "";
return of(key.trim(), value.trim());
}
......
......@@ -395,7 +395,7 @@ public class SpringApplicationBuilder {
Map<String, Object> map = new HashMap<>();
for (String property : properties) {
int index = lowestIndexOf(property, ":", "=");
String key = property.substring(0, index > 0 ? index : property.length());
String key = index > 0 ? property.substring(0, index) : property;
String value = index > 0 ? property.substring(index + 1) : "";
map.put(key, value);
}
......
......@@ -102,7 +102,7 @@ public class BindFailureAnalyzerTests {
Map<String, Object> map = new HashMap<>();
for (String pair : environment) {
int index = pair.indexOf("=");
String key = pair.substring(0, index > 0 ? index : pair.length());
String key = index > 0 ? pair.substring(0, index) : pair;
String value = index > 0 ? pair.substring(index + 1) : "";
map.put(key.trim(), value.trim());
}
......
......@@ -135,7 +135,7 @@ public class BindValidationFailureAnalyzerTests {
Map<String, Object> map = new HashMap<>();
for (String pair : environment) {
int index = pair.indexOf("=");
String key = pair.substring(0, index > 0 ? index : pair.length());
String key = index > 0 ? pair.substring(0, index) : pair;
String value = index > 0 ? pair.substring(index + 1) : "";
map.put(key.trim(), value.trim());
}
......
......@@ -98,7 +98,7 @@ public class UnboundConfigurationPropertyFailureAnalyzerTests {
Map<String, Object> map = new HashMap<>();
for (String pair : environment) {
int index = pair.indexOf("=");
String key = pair.substring(0, index > 0 ? index : pair.length());
String key = index > 0 ? pair.substring(0, index) : pair;
String value = index > 0 ? pair.substring(index + 1) : "";
map.put(key.trim(), value.trim());
}
......
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