Merge pull request #24204 from mdeinum

* pr/24204:
  Polish "Reduce the overhead of char[] creation"
  Reduce the overhead of char[] creation

Closes gh-24204
pull/24582/head
Stephane Nicoll 4 years ago
commit bb78b6ab00

@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -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++;
}

Loading…
Cancel
Save