Reduce the overhead of char[] creation

See gh-24204
This commit is contained in:
Marten Deinum
2020-11-18 13:40:01 +01:00
committed by Stephane Nicoll
parent c063c3434d
commit 5121ca5d17
4 changed files with 8 additions and 4 deletions

View File

@@ -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));
}

View File

@@ -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));
}