Avoid substring() invocation when the result is itself
Closes gh-10077
This commit is contained in:
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());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user