Polish: String function use should be optimized for single characters
This commit is contained in:
committed by
Juergen Hoeller
parent
9c55dd5961
commit
49fd724d8f
@@ -276,7 +276,7 @@ public class ContentDisposition {
|
||||
}
|
||||
else if (attribute.equals("filename*") ) {
|
||||
filename = decodeHeaderFieldParam(value);
|
||||
charset = Charset.forName(value.substring(0, value.indexOf("'")));
|
||||
charset = Charset.forName(value.substring(0, value.indexOf('\'')));
|
||||
Assert.isTrue(UTF_8.equals(charset) || ISO_8859_1.equals(charset),
|
||||
"Charset should be UTF-8 or ISO-8859-1");
|
||||
}
|
||||
@@ -362,8 +362,8 @@ public class ContentDisposition {
|
||||
*/
|
||||
private static String decodeHeaderFieldParam(String input) {
|
||||
Assert.notNull(input, "Input String should not be null");
|
||||
int firstQuoteIndex = input.indexOf("'");
|
||||
int secondQuoteIndex = input.indexOf("'", firstQuoteIndex + 1);
|
||||
int firstQuoteIndex = input.indexOf('\'');
|
||||
int secondQuoteIndex = input.indexOf('\'', firstQuoteIndex + 1);
|
||||
// US_ASCII
|
||||
if (firstQuoteIndex == -1 || secondQuoteIndex == -1) {
|
||||
return input;
|
||||
|
||||
@@ -1277,7 +1277,7 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
|
||||
// Let's only bother with DateTimeFormatter parsing for long enough values.
|
||||
|
||||
// See https://stackoverflow.com/questions/12626699/if-modified-since-http-header-passed-by-ie9-includes-length
|
||||
int parametersIndex = headerValue.indexOf(";");
|
||||
int parametersIndex = headerValue.indexOf(';');
|
||||
if (parametersIndex != -1) {
|
||||
headerValue = headerValue.substring(0, parametersIndex);
|
||||
}
|
||||
|
||||
@@ -151,7 +151,7 @@ class DefaultPathContainer implements PathContainer {
|
||||
|
||||
private static void parsePathParamValues(String input, Charset charset, MultiValueMap<String, String> output) {
|
||||
if (StringUtils.hasText(input)) {
|
||||
int index = input.indexOf("=");
|
||||
int index = input.indexOf('=');
|
||||
if (index != -1) {
|
||||
String name = input.substring(0, index);
|
||||
String value = input.substring(index + 1);
|
||||
|
||||
@@ -101,9 +101,9 @@ public class CommonsMultipartFile implements MultipartFile, Serializable {
|
||||
}
|
||||
|
||||
// Check for Unix-style path
|
||||
int unixSep = filename.lastIndexOf("/");
|
||||
int unixSep = filename.lastIndexOf('/');
|
||||
// Check for Windows-style path
|
||||
int winSep = filename.lastIndexOf("\\");
|
||||
int winSep = filename.lastIndexOf('\\');
|
||||
// Cut off at latest possible point
|
||||
int pos = (winSep > unixSep ? winSep : unixSep);
|
||||
if (pos != -1) {
|
||||
|
||||
@@ -769,8 +769,8 @@ public class UriComponentsBuilder implements UriBuilder, Cloneable {
|
||||
}
|
||||
|
||||
private void adaptForwardedHost(String hostToUse) {
|
||||
int portSeparatorIdx = hostToUse.lastIndexOf(":");
|
||||
if (portSeparatorIdx > hostToUse.lastIndexOf("]")) {
|
||||
int portSeparatorIdx = hostToUse.lastIndexOf(':');
|
||||
if (portSeparatorIdx > hostToUse.lastIndexOf(']')) {
|
||||
host(hostToUse.substring(0, portSeparatorIdx));
|
||||
port(Integer.parseInt(hostToUse.substring(portSeparatorIdx + 1)));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user