Merge pull request #10077 from izeye:substring-20170825

* pr/10077:
  Avoid substring() invocation when the result is itself
This commit is contained in:
Stephane Nicoll 2017-08-25 17:38:03 +02:00
commit a37a45921f
6 changed files with 6 additions and 6 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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