Reduce the overhead of char[] creation
See gh-24204
This commit is contained in:
committed by
Stephane Nicoll
parent
c063c3434d
commit
5121ca5d17
@@ -81,7 +81,8 @@ public class SimpleHttpCodeStatusMapper implements HttpCodeStatusMapper {
|
||||
return null;
|
||||
}
|
||||
StringBuilder builder = new StringBuilder();
|
||||
for (char ch : code.toCharArray()) {
|
||||
for (int i = 0; i < code.length(); i++) {
|
||||
char ch = code.charAt(i);
|
||||
if (Character.isAlphabetic(ch) || Character.isDigit(ch)) {
|
||||
builder.append(Character.toLowerCase(ch));
|
||||
}
|
||||
|
||||
@@ -89,7 +89,8 @@ public class SimpleStatusAggregator implements StatusAggregator {
|
||||
return null;
|
||||
}
|
||||
StringBuilder builder = new StringBuilder();
|
||||
for (char ch : code.toCharArray()) {
|
||||
for (int i = 0; i < code.length(); i++) {
|
||||
char ch = code.charAt(i);
|
||||
if (Character.isAlphabetic(ch) || Character.isDigit(ch)) {
|
||||
builder.append(Character.toLowerCase(ch));
|
||||
}
|
||||
|
||||
@@ -189,7 +189,8 @@ public class ConfigurationMetadata {
|
||||
static String toDashedCase(String name) {
|
||||
StringBuilder dashed = new StringBuilder();
|
||||
Character previous = null;
|
||||
for (char current : name.toCharArray()) {
|
||||
for (int i = 0; i < name.length(); i++) {
|
||||
char current = name.charAt(i);
|
||||
if (SEPARATORS.contains(current)) {
|
||||
dashed.append("-");
|
||||
}
|
||||
|
||||
@@ -308,7 +308,8 @@ public class ConfigTreePropertySource extends EnumerablePropertySource<Path> imp
|
||||
return string;
|
||||
}
|
||||
int numberOfLines = 0;
|
||||
for (char ch : string.toCharArray()) {
|
||||
for (int i = 0; i < string.length(); i++) {
|
||||
char ch = string.charAt(i);
|
||||
if (ch == '\n') {
|
||||
numberOfLines++;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user