Specify initial capacity when creating ArrayList in SpringFactoriesLoader

Closes gh-30271
This commit is contained in:
wizard
2023-04-03 19:56:35 +08:00
committed by Sam Brannen
parent 4eed2ced74
commit 7fcbc869a6

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2023 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.
@@ -341,8 +341,9 @@ public class SpringFactoriesLoader {
UrlResource resource = new UrlResource(urls.nextElement());
Properties properties = PropertiesLoaderUtils.loadProperties(resource);
properties.forEach((name, value) -> {
List<String> implementations = result.computeIfAbsent(((String) name).trim(), key -> new ArrayList<>());
Arrays.stream(StringUtils.commaDelimitedListToStringArray((String) value))
String[] factoryImplementationNames= StringUtils.commaDelimitedListToStringArray((String) value);
List<String> implementations = result.computeIfAbsent(((String) name).trim(), key -> new ArrayList<>(factoryImplementationNames.length));
Arrays.stream(factoryImplementationNames)
.map(String::trim).forEach(implementations::add);
});
}