From 84eacc49ed03228a7b0f9f3bc1db637e8b114b71 Mon Sep 17 00:00:00 2001 From: zhuzhuman Date: Sat, 10 Aug 2019 16:17:36 +0800 Subject: [PATCH] Simplify for statement with Collection copy See gh-17827 --- .../source/SpringIterableConfigurationPropertySource.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/source/SpringIterableConfigurationPropertySource.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/source/SpringIterableConfigurationPropertySource.java index 247b7e0c64..f0b3adf195 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/source/SpringIterableConfigurationPropertySource.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/source/SpringIterableConfigurationPropertySource.java @@ -115,9 +115,7 @@ class SpringIterableConfigurationPropertySource extends SpringConfigurationPrope String[] names = getPropertySource().getPropertyNames(); List mappings = new ArrayList<>(names.length * 2); for (String name : names) { - for (PropertyMapping mapping : getMapper().map(name)) { - mappings.add(mapping); - } + Collections.addAll(mappings, getMapper().map(name)); } result = mappings.toArray(new PropertyMapping[0]); if (cache != null) {