Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refine use of substring operations #25445

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -648,7 +648,7 @@ private PointcutBody getPointcutBody(String[] tokens, int startIndex) {
}

if (tokens[currentIndex].endsWith(")")) {
sb.append(tokens[currentIndex].substring(0, tokens[currentIndex].length() - 1));
sb.append(tokens[currentIndex], 0, tokens[currentIndex].length() - 1);
return new PointcutBody(numTokensConsumed, sb.toString().trim());
}

Expand Down
Expand Up @@ -513,7 +513,7 @@ private void addStrippedPropertyPaths(List<String> strippedPaths, String nestedP
if (endIndex != -1) {
String prefix = propertyPath.substring(0, startIndex);
String key = propertyPath.substring(startIndex, endIndex + 1);
String suffix = propertyPath.substring(endIndex + 1, propertyPath.length());
String suffix = propertyPath.substring(endIndex + 1);
// Strip the first key.
strippedPaths.add(nestedPath + prefix + suffix);
// Search for further keys to strip, with the first key stripped.
Expand Down
Expand Up @@ -107,7 +107,7 @@ private void determinePoolSizeRange(ThreadPoolTaskExecutor executor) {
int separatorIndex = this.poolSize.indexOf('-');
if (separatorIndex != -1) {
corePoolSize = Integer.parseInt(this.poolSize.substring(0, separatorIndex));
maxPoolSize = Integer.parseInt(this.poolSize.substring(separatorIndex + 1, this.poolSize.length()));
maxPoolSize = Integer.parseInt(this.poolSize.substring(separatorIndex + 1));
if (corePoolSize > maxPoolSize) {
throw new IllegalArgumentException(
"Lower bound of pool-size range must not exceed the upper bound");
Expand Down
Expand Up @@ -310,7 +310,7 @@ public void setConcurrency(String concurrency) {
int separatorIndex = concurrency.indexOf('-');
if (separatorIndex != -1) {
setConcurrentConsumers(Integer.parseInt(concurrency.substring(0, separatorIndex)));
setMaxConcurrentConsumers(Integer.parseInt(concurrency.substring(separatorIndex + 1, concurrency.length())));
setMaxConcurrentConsumers(Integer.parseInt(concurrency.substring(separatorIndex + 1)));
}
else {
setConcurrentConsumers(1);
Expand Down
Expand Up @@ -126,7 +126,7 @@ public void setConcurrency(String concurrency) {
try {
int separatorIndex = concurrency.indexOf('-');
if (separatorIndex != -1) {
setConcurrentConsumers(Integer.parseInt(concurrency.substring(separatorIndex + 1, concurrency.length())));
setConcurrentConsumers(Integer.parseInt(concurrency.substring(separatorIndex + 1)));
}
else {
setConcurrentConsumers(Integer.parseInt(concurrency));
Expand Down
Expand Up @@ -226,7 +226,7 @@ public void setConcurrency(String concurrency) {
try {
int separatorIndex = concurrency.indexOf('-');
if (separatorIndex != -1) {
setMaxConcurrency(Integer.parseInt(concurrency.substring(separatorIndex + 1, concurrency.length())));
setMaxConcurrency(Integer.parseInt(concurrency.substring(separatorIndex + 1)));
}
else {
setMaxConcurrency(Integer.parseInt(concurrency));
Expand Down
Expand Up @@ -269,7 +269,7 @@ private String unescape(String inString) {
int index = inString.indexOf('\\');

while (index >= 0) {
sb.append(inString.substring(pos, index));
sb.append(inString, pos, index);
if (index + 1 >= inString.length()) {
throw new StompConversionException("Illegal escape sequence at index " + index + ": " + inString);
}
Expand Down
Expand Up @@ -212,7 +212,7 @@ else if (sb != null){
private StringBuilder getStringBuilder(@Nullable StringBuilder sb, String inString, int i) {
if (sb == null) {
sb = new StringBuilder(inString.length());
sb.append(inString.substring(0, i));
sb.append(inString, 0, i);
}
return sb;
}
Expand Down
Expand Up @@ -71,7 +71,7 @@ public PatternMappingFilterProxy(Filter delegate, String... urlPatterns) {
private void addUrlPattern(String urlPattern) {
Assert.notNull(urlPattern, "Found null URL Pattern");
if (urlPattern.startsWith(EXTENSION_MAPPING_PATTERN)) {
this.endsWithMatches.add(urlPattern.substring(1, urlPattern.length()));
this.endsWithMatches.add(urlPattern.substring(1));
}
else if (urlPattern.equals(PATH_MAPPING_PATTERN)) {
this.startsWithMatches.add("");
Expand Down
Expand Up @@ -225,7 +225,7 @@ else if (c == '}') {
throw new IllegalArgumentException(
"No custom regular expression specified after ':' in \"" + variable + "\"");
}
String regex = variable.substring(idx + 1, variable.length());
String regex = variable.substring(idx + 1);
pattern.append('(');
pattern.append(regex);
pattern.append(')');
Expand Down
Expand Up @@ -245,12 +245,12 @@ protected StringBuilder expandTargetUrlTemplate(String targetUrl,
String name = matcher.group(1);
Object value = (model.containsKey(name) ? model.get(name) : uriVariables.get(name));
Assert.notNull(value, () -> "No value for URI variable '" + name + "'");
result.append(targetUrl.substring(endLastMatch, matcher.start()));
result.append(targetUrl, endLastMatch, matcher.start());
result.append(encodeUriVariable(value.toString()));
endLastMatch = matcher.end();
found = matcher.find();
}
result.append(targetUrl.substring(endLastMatch, targetUrl.length()));
result.append(targetUrl.substring(endLastMatch));
return result;
}

Expand Down
Expand Up @@ -278,7 +278,7 @@ String createUrl() throws JspException {
}
else {
if (this.context.endsWith("/")) {
url.append(this.context.substring(0, this.context.length() - 1));
url.append(this.context, 0, this.context.length() - 1);
}
else {
url.append(this.context);
Expand Down
Expand Up @@ -386,7 +386,7 @@ protected StringBuilder replaceUriTemplateVariables(
if (value == null) {
throw new IllegalArgumentException("Model has no value for key '" + name + "'");
}
result.append(targetUrl.substring(endLastMatch, matcher.start()));
result.append(targetUrl, endLastMatch, matcher.start());
result.append(UriUtils.encodePathSegment(value.toString(), encodingScheme));
endLastMatch = matcher.end();
}
Expand Down
Expand Up @@ -160,7 +160,7 @@ private static WebSocketExtension parseExtension(String extension) {
int eqIndex = parameter.indexOf('=');
if (eqIndex != -1) {
String attribute = parameter.substring(0, eqIndex);
String value = parameter.substring(eqIndex + 1, parameter.length());
String value = parameter.substring(eqIndex + 1);
parameters.put(attribute, value);
}
}
Expand Down