From de30e5c6ac1c1e7e215963278cbeb54f94f7f86e Mon Sep 17 00:00:00 2001 From: dreis2211 Date: Tue, 14 Jul 2020 17:54:08 +0200 Subject: [PATCH] Avoid unnecessary allocations in ConditionMessage for NORMAL style See gh-22330 --- .../boot/autoconfigure/condition/ConditionMessage.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/ConditionMessage.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/ConditionMessage.java index 18f2e07416..68b6fafb81 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/ConditionMessage.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/ConditionMessage.java @@ -405,6 +405,11 @@ public final class ConditionMessage { protected Object applyToItem(Object item) { return item; } + + @Override + public Collection applyTo(Collection items) { + return items; + } }, QUOTE { @@ -415,7 +420,7 @@ public final class ConditionMessage { }; public Collection applyTo(Collection items) { - List result = new ArrayList<>(); + List result = new ArrayList<>(items.size()); for (Object item : items) { result.add(applyToItem(item)); }