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

(cherry picked from commit 4a147d26fc)
This commit is contained in:
Juergen Hoeller
2018-07-30 22:07:31 +02:00
parent 006db06d11
commit 91fa2ed0d4
19 changed files with 52 additions and 55 deletions

View File

@@ -43,7 +43,7 @@ import org.springframework.util.ObjectUtils;
*/
public class ConstructorArgumentValues {
private final Map<Integer, ValueHolder> indexedArgumentValues = new LinkedHashMap<>(0);
private final Map<Integer, ValueHolder> indexedArgumentValues = new LinkedHashMap<>();
private final List<ValueHolder> genericArgumentValues = new ArrayList<>();

View File

@@ -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.
@@ -158,7 +158,7 @@ public abstract class AbstractBeanDefinition extends BeanMetadataAttributeAccess
private boolean primary = false;
private final Map<String, AutowireCandidateQualifier> qualifiers = new LinkedHashMap<>(0);
private final Map<String, AutowireCandidateQualifier> qualifiers = new LinkedHashMap<>();
@Nullable
private Supplier<?> instanceSupplier;
@@ -470,7 +470,7 @@ public abstract class AbstractBeanDefinition extends BeanMetadataAttributeAccess
*/
@Override
public boolean isSingleton() {
return SCOPE_SINGLETON.equals(scope) || SCOPE_DEFAULT.equals(scope);
return SCOPE_SINGLETON.equals(this.scope) || SCOPE_DEFAULT.equals(this.scope);
}
/**
@@ -480,7 +480,7 @@ public abstract class AbstractBeanDefinition extends BeanMetadataAttributeAccess
*/
@Override
public boolean isPrototype() {
return SCOPE_PROTOTYPE.equals(scope);
return SCOPE_PROTOTYPE.equals(this.scope);
}
/**