Optimize BeanPropertyName.toDashedForm()

See gh-15779
This commit is contained in:
dreis2211 2019-01-24 16:21:48 +01:00 committed by Andy Wilkinson
parent 49ff4b77f9
commit 3c8d9d00e5
1 changed files with 4 additions and 4 deletions

View File

@ -44,12 +44,12 @@ abstract class BeanPropertyName {
*/
public static String toDashedForm(String name, int start) {
StringBuilder result = new StringBuilder();
char[] chars = name.replace("_", "-").toCharArray();
for (int i = start; i < chars.length; i++) {
char ch = chars[i];
String replaced = name.replace('_', '-');
for (int i = start; i < replaced.length(); i++) {
char ch = replaced.charAt(i);
if (Character.isUpperCase(ch) && result.length() > 0
&& result.charAt(result.length() - 1) != '-') {
result.append("-");
result.append('-');
}
result.append(Character.toLowerCase(ch));
}