Initialize pre-filled HashMaps with large enough capacity
Empty Maps are preferably initialized without capacity (not initializing them at all or lazily initializing with default capacity when needed). Issue: SPR-17105
This commit is contained in:
@@ -78,7 +78,7 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
|
||||
/**
|
||||
* The empty {@code HttpHeaders} instance (immutable).
|
||||
*/
|
||||
public static final HttpHeaders EMPTY = new HttpHeaders(new LinkedHashMap<>(0), true);
|
||||
public static final HttpHeaders EMPTY = new HttpHeaders(new LinkedHashMap<>(), true);
|
||||
/**
|
||||
* The HTTP {@code Accept} header field name.
|
||||
* @see <a href="http://tools.ietf.org/html/rfc7231#section-5.3.2">Section 5.3.2 of RFC 7231</a>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 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.
|
||||
@@ -35,7 +35,7 @@ public enum HttpMethod {
|
||||
GET, HEAD, POST, PUT, PATCH, DELETE, OPTIONS, TRACE;
|
||||
|
||||
|
||||
private static final Map<String, HttpMethod> mappings = new HashMap<>(8);
|
||||
private static final Map<String, HttpMethod> mappings = new HashMap<>(16);
|
||||
|
||||
static {
|
||||
for (HttpMethod httpMethod : values()) {
|
||||
|
||||
@@ -38,7 +38,7 @@ import org.springframework.util.StringUtils;
|
||||
*/
|
||||
final class DefaultPathContainer implements PathContainer {
|
||||
|
||||
private static final MultiValueMap<String, String> EMPTY_MAP = new LinkedMultiValueMap<>(0);
|
||||
private static final MultiValueMap<String, String> EMPTY_MAP = new LinkedMultiValueMap<>();
|
||||
|
||||
private static final PathContainer EMPTY_PATH = new DefaultPathContainer("", Collections.emptyList());
|
||||
|
||||
|
||||
@@ -55,54 +55,46 @@ final class HierarchicalUriComponents extends UriComponents {
|
||||
|
||||
private static final String PATH_DELIMITER_STRING = "/";
|
||||
|
||||
private static final MultiValueMap<String, String> EMPTY_QUERY_PARAMS =
|
||||
CollectionUtils.unmodifiableMultiValueMap(new LinkedMultiValueMap<>());
|
||||
|
||||
|
||||
/**
|
||||
* Represents an empty path.
|
||||
*/
|
||||
static final PathComponent NULL_PATH_COMPONENT = new PathComponent() {
|
||||
|
||||
@Override
|
||||
public String getPath() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getPathSegments() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PathComponent encode(BiFunction<String, Type, String> encoder) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void verify() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public PathComponent expand(UriTemplateVariables uriVariables, @Nullable UnaryOperator<String> encoder) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copyToUriComponentsBuilder(UriComponentsBuilder builder) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
return (this == other);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return getClass().hashCode();
|
||||
}
|
||||
};
|
||||
|
||||
private static final MultiValueMap<String, String> EMPTY_QUERY_PARAMS =
|
||||
CollectionUtils.unmodifiableMultiValueMap(new LinkedMultiValueMap<>(0));
|
||||
|
||||
|
||||
@Nullable
|
||||
private final String userInfo;
|
||||
|
||||
@@ -55,7 +55,7 @@ class HtmlCharacterEntityReferences {
|
||||
|
||||
private final String[] characterToEntityReferenceMap = new String[3000];
|
||||
|
||||
private final Map<String, Character> entityReferenceToCharacterMap = new HashMap<>(252);
|
||||
private final Map<String, Character> entityReferenceToCharacterMap = new HashMap<>(512);
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -38,7 +38,7 @@ import org.springframework.util.ObjectUtils;
|
||||
@SuppressWarnings("serial")
|
||||
final class OpaqueUriComponents extends UriComponents {
|
||||
|
||||
private static final MultiValueMap<String, String> QUERY_PARAMS_NONE = new LinkedMultiValueMap<>(0);
|
||||
private static final MultiValueMap<String, String> QUERY_PARAMS_NONE = new LinkedMultiValueMap<>();
|
||||
|
||||
@Nullable
|
||||
private final String ssp;
|
||||
|
||||
Reference in New Issue
Block a user