Polish: String function use should be optimized for single characters
This commit is contained in:
committed by
Juergen Hoeller
parent
9c55dd5961
commit
49fd724d8f
@@ -238,7 +238,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("/")));
|
||||
}
|
||||
|
||||
|
||||
@@ -151,7 +151,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;
|
||||
}
|
||||
|
||||
|
||||
@@ -151,11 +151,11 @@ public class ResourceUrlProvider implements ApplicationListener<ContextRefreshed
|
||||
|
||||
private int getQueryIndex(String path) {
|
||||
int suffixIndex = path.length();
|
||||
int queryIndex = path.indexOf("?");
|
||||
int queryIndex = path.indexOf('?');
|
||||
if (queryIndex > 0) {
|
||||
suffixIndex = queryIndex;
|
||||
}
|
||||
int hashIndex = path.indexOf("#");
|
||||
int hashIndex = path.indexOf('#');
|
||||
if (hashIndex > 0) {
|
||||
suffixIndex = Math.min(suffixIndex, hashIndex);
|
||||
}
|
||||
|
||||
@@ -107,7 +107,7 @@ public class WebJarsResourceResolver extends AbstractResourceResolver {
|
||||
protected String findWebJarResourcePath(String path) {
|
||||
try {
|
||||
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);
|
||||
|
||||
@@ -268,7 +268,7 @@ public class RedirectView extends AbstractUrlBasedView {
|
||||
return new StringBuilder(targetUrl);
|
||||
}
|
||||
|
||||
int index = targetUrl.indexOf("#");
|
||||
int index = targetUrl.indexOf('#');
|
||||
String fragment = (index > -1 ? targetUrl.substring(index) : null);
|
||||
|
||||
StringBuilder result = new StringBuilder();
|
||||
|
||||
Reference in New Issue
Block a user