Polish: String function use should be optimized for single characters
(cherry picked from commit 49fd724)
This commit is contained in:
committed by
Juergen Hoeller
parent
073e78b68d
commit
39ddd0f349
@@ -139,7 +139,7 @@ public class UrlFilenameViewController extends AbstractUrlViewController {
|
||||
*/
|
||||
protected String extractViewNameFromUrlPath(String uri) {
|
||||
int start = (uri.charAt(0) == '/' ? 1 : 0);
|
||||
int lastIndex = uri.lastIndexOf(".");
|
||||
int lastIndex = uri.lastIndexOf('.');
|
||||
int end = (lastIndex < 0 ? uri.length() : lastIndex);
|
||||
return uri.substring(start, end);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -190,7 +190,7 @@ public class AppCacheManifestTransformer extends ResourceTransformerSupport {
|
||||
}
|
||||
|
||||
private boolean hasScheme(String link) {
|
||||
int schemeIndex = link.indexOf(":");
|
||||
int schemeIndex = link.indexOf(':');
|
||||
return (link.startsWith("//") || (schemeIndex > 0 && !link.substring(0, schemeIndex).contains("/")));
|
||||
}
|
||||
|
||||
|
||||
@@ -121,7 +121,7 @@ public class CssLinkResourceTransformer extends ResourceTransformerSupport {
|
||||
}
|
||||
|
||||
private boolean hasScheme(String link) {
|
||||
int schemeIndex = link.indexOf(":");
|
||||
int schemeIndex = link.indexOf(':');
|
||||
return (schemeIndex > 0 && !link.substring(0, schemeIndex).contains("/")) || link.indexOf("//") == 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -349,7 +349,7 @@ public class ResourceHttpRequestHandler extends WebContentGenerator
|
||||
Charset charset = null;
|
||||
location = location.trim();
|
||||
if (location.startsWith(URL_RESOURCE_CHARSET_PREFIX)) {
|
||||
int endIndex = location.indexOf("]", URL_RESOURCE_CHARSET_PREFIX.length());
|
||||
int endIndex = location.indexOf(']', URL_RESOURCE_CHARSET_PREFIX.length());
|
||||
if (endIndex == -1) {
|
||||
throw new IllegalArgumentException("Invalid charset syntax in location: " + location);
|
||||
}
|
||||
|
||||
@@ -120,7 +120,7 @@ public class ResourceUrlEncodingFilter extends GenericFilterBean {
|
||||
}
|
||||
|
||||
private int getQueryParamsIndex(String url) {
|
||||
int index = url.indexOf("?");
|
||||
int index = url.indexOf('?');
|
||||
return (index > 0 ? index : url.length());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -198,11 +198,11 @@ public class ResourceUrlProvider implements ApplicationListener<ContextRefreshed
|
||||
|
||||
private int getEndPathIndex(String lookupPath) {
|
||||
int suffixIndex = lookupPath.length();
|
||||
int queryIndex = lookupPath.indexOf("?");
|
||||
int queryIndex = lookupPath.indexOf('?');
|
||||
if(queryIndex > 0) {
|
||||
suffixIndex = queryIndex;
|
||||
}
|
||||
int hashIndex = lookupPath.indexOf("#");
|
||||
int hashIndex = lookupPath.indexOf('#');
|
||||
if(hashIndex > 0) {
|
||||
suffixIndex = Math.min(suffixIndex, hashIndex);
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ public class WebJarsResourceResolver extends AbstractResourceResolver {
|
||||
|
||||
protected String findWebJarResourcePath(String path) {
|
||||
int startOffset = (path.startsWith("/") ? 1 : 0);
|
||||
int endOffset = path.indexOf("/", 1);
|
||||
int endOffset = path.indexOf('/', 1);
|
||||
if (endOffset != -1) {
|
||||
String webjar = path.substring(startOffset, endOffset);
|
||||
String partialPath = path.substring(endOffset + 1);
|
||||
|
||||
@@ -126,7 +126,7 @@ public abstract class AbstractView extends WebApplicationObjectSupport implement
|
||||
StringTokenizer st = new StringTokenizer(propString, ",");
|
||||
while (st.hasMoreTokens()) {
|
||||
String tok = st.nextToken();
|
||||
int eqIdx = tok.indexOf("=");
|
||||
int eqIdx = tok.indexOf('=');
|
||||
if (eqIdx == -1) {
|
||||
throw new IllegalArgumentException("Expected = in attributes CSV string '" + propString + "'");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user