Prefer ArrayList/ArrayDeque over LinkedList for multi-element holders
LinkedList remains in place where a List is likely to remain empty or single-element (in order to avoid unused capacity). Issue: SPR-17037
This commit is contained in:
@@ -28,10 +28,11 @@ import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
@@ -350,12 +351,11 @@ public class CommonAnnotationBeanPostProcessor extends InitDestroyAnnotationBean
|
||||
}
|
||||
|
||||
private InjectionMetadata buildResourceMetadata(final Class<?> clazz) {
|
||||
LinkedList<InjectionMetadata.InjectedElement> elements = new LinkedList<>();
|
||||
List<InjectionMetadata.InjectedElement> elements = new ArrayList<>();
|
||||
Class<?> targetClass = clazz;
|
||||
|
||||
do {
|
||||
final LinkedList<InjectionMetadata.InjectedElement> currElements =
|
||||
new LinkedList<>();
|
||||
final List<InjectionMetadata.InjectedElement> currElements = new ArrayList<>();
|
||||
|
||||
ReflectionUtils.doWithLocalFields(targetClass, field -> {
|
||||
if (webServiceRefClass != null && field.isAnnotationPresent(webServiceRefClass)) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
@@ -16,9 +16,10 @@
|
||||
|
||||
package org.springframework.context.event;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
@@ -213,7 +214,7 @@ public abstract class AbstractApplicationEventMulticaster
|
||||
private Collection<ApplicationListener<?>> retrieveApplicationListeners(
|
||||
ResolvableType eventType, @Nullable Class<?> sourceType, @Nullable ListenerRetriever retriever) {
|
||||
|
||||
LinkedList<ApplicationListener<?>> allListeners = new LinkedList<>();
|
||||
List<ApplicationListener<?>> allListeners = new ArrayList<>();
|
||||
Set<ApplicationListener<?>> listeners;
|
||||
Set<String> listenerBeans;
|
||||
synchronized (this.retrievalMutex) {
|
||||
@@ -368,10 +369,9 @@ public abstract class AbstractApplicationEventMulticaster
|
||||
}
|
||||
|
||||
public Collection<ApplicationListener<?>> getApplicationListeners() {
|
||||
LinkedList<ApplicationListener<?>> allListeners = new LinkedList<>();
|
||||
for (ApplicationListener<?> listener : this.applicationListeners) {
|
||||
allListeners.add(listener);
|
||||
}
|
||||
List<ApplicationListener<?>> allListeners = new ArrayList<>(
|
||||
this.applicationListeners.size() + this.applicationListenerBeans.size());
|
||||
allListeners.addAll(this.applicationListeners);
|
||||
if (!this.applicationListenerBeans.isEmpty()) {
|
||||
BeanFactory beanFactory = getBeanFactory();
|
||||
for (String listenerBeanName : this.applicationListenerBeans) {
|
||||
|
||||
@@ -20,7 +20,6 @@ import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -61,8 +60,8 @@ final class PostProcessorRegistrationDelegate {
|
||||
|
||||
if (beanFactory instanceof BeanDefinitionRegistry) {
|
||||
BeanDefinitionRegistry registry = (BeanDefinitionRegistry) beanFactory;
|
||||
List<BeanFactoryPostProcessor> regularPostProcessors = new LinkedList<>();
|
||||
List<BeanDefinitionRegistryPostProcessor> registryProcessors = new LinkedList<>();
|
||||
List<BeanFactoryPostProcessor> regularPostProcessors = new ArrayList<>();
|
||||
List<BeanDefinitionRegistryPostProcessor> registryProcessors = new ArrayList<>();
|
||||
|
||||
for (BeanFactoryPostProcessor postProcessor : beanFactoryPostProcessors) {
|
||||
if (postProcessor instanceof BeanDefinitionRegistryPostProcessor) {
|
||||
|
||||
Reference in New Issue
Block a user