Replace remaining usage of LinkedList with ArrayList/ArrayDeque
Closes gh-25650
This commit is contained in:
@@ -23,7 +23,6 @@ import java.util.Collections;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
@@ -897,7 +896,7 @@ public class DispatcherServlet extends FrameworkServlet {
|
||||
return strategies;
|
||||
}
|
||||
else {
|
||||
return new LinkedList<>();
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2020 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,8 +16,8 @@
|
||||
|
||||
package org.springframework.web.servlet.support;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
@@ -127,7 +127,7 @@ public abstract class AbstractFlashMapManager implements FlashMapManager {
|
||||
* Return a list of expired FlashMap instances contained in the given list.
|
||||
*/
|
||||
private List<FlashMap> getExpiredFlashMaps(List<FlashMap> allMaps) {
|
||||
List<FlashMap> result = new LinkedList<>();
|
||||
List<FlashMap> result = new ArrayList<>();
|
||||
for (FlashMap map : allMaps) {
|
||||
if (map.isExpired()) {
|
||||
result.add(map);
|
||||
@@ -142,7 +142,7 @@ public abstract class AbstractFlashMapManager implements FlashMapManager {
|
||||
*/
|
||||
@Nullable
|
||||
private FlashMap getMatchingFlashMap(List<FlashMap> allMaps, HttpServletRequest request) {
|
||||
List<FlashMap> result = new LinkedList<>();
|
||||
List<FlashMap> result = new ArrayList<>();
|
||||
for (FlashMap flashMap : allMaps) {
|
||||
if (isFlashMapForRequest(flashMap, request)) {
|
||||
result.add(flashMap);
|
||||
@@ -213,7 +213,7 @@ public abstract class AbstractFlashMapManager implements FlashMapManager {
|
||||
}
|
||||
else {
|
||||
List<FlashMap> allFlashMaps = retrieveFlashMaps(request);
|
||||
allFlashMaps = (allFlashMaps != null ? allFlashMaps : new LinkedList<>());
|
||||
allFlashMaps = (allFlashMaps != null ? allFlashMaps : new ArrayList<>(1));
|
||||
allFlashMaps.add(flashMap);
|
||||
updateFlashMaps(allFlashMaps, request, response);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2020 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.
|
||||
@@ -17,9 +17,9 @@
|
||||
package org.springframework.web.servlet.tags;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.jsp.JspException;
|
||||
@@ -255,7 +255,7 @@ public class MessageTag extends HtmlEscapingAwareTag implements ArgumentAware {
|
||||
|
||||
@Override
|
||||
protected final int doStartTagInternal() throws JspException, IOException {
|
||||
this.nestedArguments = new LinkedList<>();
|
||||
this.nestedArguments = new ArrayList<>();
|
||||
return EVAL_BODY_INCLUDE;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,9 +18,9 @@ package org.springframework.web.servlet.tags;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.UnsupportedCharsetException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -229,7 +229,7 @@ public class UrlTag extends HtmlEscapingAwareTag implements ParamAware {
|
||||
|
||||
@Override
|
||||
public int doStartTagInternal() throws JspException {
|
||||
this.params = new LinkedList<>();
|
||||
this.params = new ArrayList<>();
|
||||
this.templateParams = new HashSet<>();
|
||||
return EVAL_BODY_INCLUDE;
|
||||
}
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
|
||||
package org.springframework.web.servlet.view;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
@@ -230,10 +230,9 @@ public class ResourceBundleViewResolver extends AbstractCachingViewResolver
|
||||
}
|
||||
|
||||
// Build list of ResourceBundle references for Locale.
|
||||
List<ResourceBundle> bundles = new LinkedList<>();
|
||||
List<ResourceBundle> bundles = new ArrayList<>(this.basenames.length);
|
||||
for (String basename : this.basenames) {
|
||||
ResourceBundle bundle = getBundle(basename, locale);
|
||||
bundles.add(bundle);
|
||||
bundles.add(getBundle(basename, locale));
|
||||
}
|
||||
|
||||
// Try to find cached factory for ResourceBundle list:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2020 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,8 +16,8 @@
|
||||
|
||||
package org.springframework.web.servlet.view.tiles3;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.el.ArrayELResolver;
|
||||
@@ -311,7 +311,7 @@ public class TilesConfigurer implements ServletContextAware, InitializingBean, D
|
||||
@Override
|
||||
protected List<ApplicationResource> getSources(ApplicationContext applicationContext) {
|
||||
if (definitions != null) {
|
||||
List<ApplicationResource> result = new LinkedList<>();
|
||||
List<ApplicationResource> result = new ArrayList<>();
|
||||
for (String definition : definitions) {
|
||||
Collection<ApplicationResource> resources = applicationContext.getResources(definition);
|
||||
if (resources != null) {
|
||||
|
||||
Reference in New Issue
Block a user