Merge pull request #10077 from izeye:substring-20170825
* pr/10077: Avoid substring() invocation when the result is itself
This commit is contained in:
commit
a37a45921f
|
@ -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…
Reference in New Issue