From f34fb5f1ee51b2bd952caddaedb68e2e11b8a8f0 Mon Sep 17 00:00:00 2001 From: Johnny Lim Date: Fri, 15 Jun 2018 05:29:19 +0900 Subject: [PATCH] Reduce object creation in findMatchingItemMetadata() Closes gh-13473 --- .../metadata/ConfigurationMetadata.java | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/metadata/ConfigurationMetadata.java b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/metadata/ConfigurationMetadata.java index c9405a4ef2..6c377ef71d 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/metadata/ConfigurationMetadata.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/metadata/ConfigurationMetadata.java @@ -145,10 +145,11 @@ public class ConfigurationMetadata { } private ItemMetadata findMatchingItemMetadata(ItemMetadata metadata) { - List candidates = getCandidates(metadata.getName()); - if (candidates.isEmpty()) { + List candidates = this.items.get(metadata.getName()); + if (candidates == null || candidates.isEmpty()) { return null; } + candidates = new ArrayList<>(candidates); candidates.removeIf((itemMetadata) -> !itemMetadata.hasSameType(metadata)); if (candidates.size() > 1 && metadata.getType() != null) { candidates.removeIf( @@ -165,11 +166,6 @@ public class ConfigurationMetadata { return null; } - private List getCandidates(String name) { - List candidates = this.items.get(name); - return (candidates != null ? new ArrayList<>(candidates) : new ArrayList<>()); - } - private boolean nullSafeEquals(Object o1, Object o2) { if (o1 == o2) { return true;