From 3c8d9d00e5110afcb84d12e12dc3a5e89ff092e7 Mon Sep 17 00:00:00 2001 From: dreis2211 Date: Thu, 24 Jan 2019 16:21:48 +0100 Subject: [PATCH 1/2] 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 068c4ccf00..6c7eefca3c 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)); } From 0e77445a9a521c9215a7710b84c5a62808b88129 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Mon, 28 Jan 2019 11:37:24 +0000 Subject: [PATCH 2/2] Polish "Optimize BeanPropertyName.toDashedForm()" See gh-15779 --- .../boot/context/properties/bind/BeanPropertyName.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 6c7eefca3c..79131ebac8 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 @@ -1,5 +1,5 @@ /* - * 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.