From 3c8d9d00e5110afcb84d12e12dc3a5e89ff092e7 Mon Sep 17 00:00:00 2001 From: dreis2211 Date: Thu, 24 Jan 2019 16:21:48 +0100 Subject: [PATCH] Optimize BeanPropertyName.toDashedForm() See gh-15779 --- .../boot/context/properties/bind/BeanPropertyName.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/BeanPropertyName.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/BeanPropertyName.java index 068c4ccf005..6c7eefca3cc 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/BeanPropertyName.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/BeanPropertyName.java @@ -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)); }