Polish: String function use should be optimized for single characters

(cherry picked from commit 49fd724)
This commit is contained in:
igor-suhorukov
2018-02-25 20:34:35 +01:00
committed by Juergen Hoeller
parent 073e78b68d
commit 39ddd0f349
23 changed files with 32 additions and 32 deletions

View File

@@ -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) {

View File

@@ -713,8 +713,8 @@ public class UriComponentsBuilder implements 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)));
}