Skip to content

Commit 7ed92e9

Browse files
committed
Merge pull request #15779 from Christoph Dreiss
* gh-15779: Polish "Optimize BeanPropertyName.toDashedForm()" Optimize BeanPropertyName.toDashedForm() Closes gh-15779
2 parents 49ff4b7 + 0e77445 commit 7ed92e9

File tree

1 file changed

+5
-5
lines changed
  • spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind

1 file changed

+5
-5
lines changed

spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/BeanPropertyName.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2017 the original author or authors.
2+
* Copyright 2012-2019 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.
@@ -44,12 +44,12 @@ public static String toDashedForm(String name) {
4444
*/
4545
public static String toDashedForm(String name, int start) {
4646
StringBuilder result = new StringBuilder();
47-
char[] chars = name.replace("_", "-").toCharArray();
48-
for (int i = start; i < chars.length; i++) {
49-
char ch = chars[i];
47+
String replaced = name.replace('_', '-');
48+
for (int i = start; i < replaced.length(); i++) {
49+
char ch = replaced.charAt(i);
5050
if (Character.isUpperCase(ch) && result.length() > 0
5151
&& result.charAt(result.length() - 1) != '-') {
52-
result.append("-");
52+
result.append('-');
5353
}
5454
result.append(Character.toLowerCase(ch));
5555
}

0 commit comments

Comments
 (0)