Commit 5121ca5d authored by Marten Deinum's avatar Marten Deinum Committed by Stephane Nicoll

Reduce the overhead of char[] creation

See gh-24204
parent c063c343
...@@ -81,7 +81,8 @@ public class SimpleHttpCodeStatusMapper implements HttpCodeStatusMapper { ...@@ -81,7 +81,8 @@ public class SimpleHttpCodeStatusMapper implements HttpCodeStatusMapper {
return null; return null;
} }
StringBuilder builder = new StringBuilder(); 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)) { if (Character.isAlphabetic(ch) || Character.isDigit(ch)) {
builder.append(Character.toLowerCase(ch)); builder.append(Character.toLowerCase(ch));
} }
......
...@@ -89,7 +89,8 @@ public class SimpleStatusAggregator implements StatusAggregator { ...@@ -89,7 +89,8 @@ public class SimpleStatusAggregator implements StatusAggregator {
return null; return null;
} }
StringBuilder builder = new StringBuilder(); 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)) { if (Character.isAlphabetic(ch) || Character.isDigit(ch)) {
builder.append(Character.toLowerCase(ch)); builder.append(Character.toLowerCase(ch));
} }
......
...@@ -189,7 +189,8 @@ public class ConfigurationMetadata { ...@@ -189,7 +189,8 @@ public class ConfigurationMetadata {
static String toDashedCase(String name) { static String toDashedCase(String name) {
StringBuilder dashed = new StringBuilder(); StringBuilder dashed = new StringBuilder();
Character previous = null; 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)) { if (SEPARATORS.contains(current)) {
dashed.append("-"); dashed.append("-");
} }
......
...@@ -308,7 +308,8 @@ public class ConfigTreePropertySource extends EnumerablePropertySource<Path> imp ...@@ -308,7 +308,8 @@ public class ConfigTreePropertySource extends EnumerablePropertySource<Path> imp
return string; return string;
} }
int numberOfLines = 0; int numberOfLines = 0;
for (char ch : string.toCharArray()) { for (int i = 0; i < string.length(); i++) {
char ch = string.charAt(i);
if (ch == '\n') { if (ch == '\n') {
numberOfLines++; numberOfLines++;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment