Avoid substring() invocation when the result is itself

Closes gh-10077
pull/10079/head
Johnny Lim 7 years ago committed by Stephane Nicoll
parent 8198b87538
commit 4ae3691fee

@ -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());
}

Loading…
Cancel
Save