Commit 7ed92e9b authored by Andy Wilkinson's avatar Andy Wilkinson

Merge pull request #15779 from Christoph Dreiss

* gh-15779:
  Polish "Optimize BeanPropertyName.toDashedForm()"
  Optimize BeanPropertyName.toDashedForm()

Closes gh-15779
parents 49ff4b77 0e77445a
/*
* Copyright 2012-2017 the original author or authors.
* Copyright 2012-2019 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.
......@@ -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));
}
......
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