diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/source/ConfigurationPropertyName.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/source/ConfigurationPropertyName.java index 0af5f76fdc5..ad3e5b3350c 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/source/ConfigurationPropertyName.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/source/ConfigurationPropertyName.java @@ -373,8 +373,9 @@ public final class ConfigurationPropertyName ElementType.DASHED)) { return this.elements.getSource().toString(); } - StringBuilder result = new StringBuilder(); - for (int i = 0; i < getNumberOfElements(); i++) { + int elements = getNumberOfElements(); + StringBuilder result = new StringBuilder(elements * 8); + for (int i = 0; i < elements; i++) { boolean indexed = isIndexed(i); if (result.length() > 0 && !indexed) { result.append('.');