Polish: String function use should be optimized for single characters
This commit is contained in:
committed by
Juergen Hoeller
parent
9c55dd5961
commit
49fd724d8f
@@ -140,7 +140,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);
|
||||
}
|
||||
|
||||
@@ -195,7 +195,7 @@ public class AppCacheManifestTransformer extends ResourceTransformerSupport {
|
||||
}
|
||||
|
||||
private static boolean hasScheme(String line) {
|
||||
int index = line.indexOf(":");
|
||||
int index = line.indexOf(':');
|
||||
return (line.startsWith("//") || (index > 0 && !line.substring(0, index).contains("/")));
|
||||
}
|
||||
|
||||
|
||||
@@ -120,7 +120,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;
|
||||
}
|
||||
|
||||
|
||||
@@ -355,7 +355,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);
|
||||
}
|
||||
|
||||
@@ -123,7 +123,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());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -193,11 +193,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);
|
||||
}
|
||||
|
||||
@@ -101,7 +101,7 @@ public class WebJarsResourceResolver extends AbstractResourceResolver {
|
||||
@Nullable
|
||||
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);
|
||||
|
||||
@@ -136,7 +136,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