Skip to content

Commit bb78b6a

Browse files
committed
Merge pull request #24204 from mdeinum
* pr/24204: Polish "Reduce the overhead of char[] creation" Reduce the overhead of char[] creation Closes gh-24204
2 parents c063c34 + 5da27ea commit bb78b6a

File tree

4 files changed

+9
-5
lines changed

4 files changed

+9
-5
lines changed

spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/SimpleHttpCodeStatusMapper.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2019 the original author or authors.
2+
* Copyright 2012-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -81,7 +81,8 @@ private static String getUniformCode(String code) {
8181
return null;
8282
}
8383
StringBuilder builder = new StringBuilder();
84-
for (char ch : code.toCharArray()) {
84+
for (int i = 0; i < code.length(); i++) {
85+
char ch = code.charAt(i);
8586
if (Character.isAlphabetic(ch) || Character.isDigit(ch)) {
8687
builder.append(Character.toLowerCase(ch));
8788
}

spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/SimpleStatusAggregator.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,8 @@ private static String getUniformCode(String code) {
8989
return null;
9090
}
9191
StringBuilder builder = new StringBuilder();
92-
for (char ch : code.toCharArray()) {
92+
for (int i = 0; i < code.length(); i++) {
93+
char ch = code.charAt(i);
9394
if (Character.isAlphabetic(ch) || Character.isDigit(ch)) {
9495
builder.append(Character.toLowerCase(ch));
9596
}

spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/metadata/ConfigurationMetadata.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,8 @@ public static String nestedPrefix(String prefix, String name) {
189189
static String toDashedCase(String name) {
190190
StringBuilder dashed = new StringBuilder();
191191
Character previous = null;
192-
for (char current : name.toCharArray()) {
192+
for (int i = 0; i < name.length(); i++) {
193+
char current = name.charAt(i);
193194
if (SEPARATORS.contains(current)) {
194195
dashed.append("-");
195196
}

spring-boot-project/spring-boot/src/main/java/org/springframework/boot/env/ConfigTreePropertySource.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,8 @@ private String autoTrimTrailingNewLine(String string) {
308308
return string;
309309
}
310310
int numberOfLines = 0;
311-
for (char ch : string.toCharArray()) {
311+
for (int i = 0; i < string.length(); i++) {
312+
char ch = string.charAt(i);
312313
if (ch == '\n') {
313314
numberOfLines++;
314315
}

0 commit comments

Comments
 (0)