mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 06:45:07 +02:00
8186958: Need method to create pre-sized HashMap
Reviewed-by: chegar, naoto, joehw, lancea, wetmore, smarks
This commit is contained in:
parent
41fc078323
commit
87faa85c59
30 changed files with 208 additions and 73 deletions
|
@ -3910,7 +3910,7 @@ public final class Class<T> implements java.io.Serializable,
|
|||
if (universe == null)
|
||||
throw new IllegalArgumentException(
|
||||
getName() + " is not an enum class");
|
||||
directory = new HashMap<>((int)(universe.length / 0.75f) + 1);
|
||||
directory = HashMap.newHashMap(universe.length);
|
||||
for (T constant : universe) {
|
||||
directory.put(((Enum<?>)constant).name(), constant);
|
||||
}
|
||||
|
@ -4125,10 +4125,10 @@ public final class Class<T> implements java.io.Serializable,
|
|||
Class<? extends Annotation> annotationClass = e.getKey();
|
||||
if (AnnotationType.getInstance(annotationClass).isInherited()) {
|
||||
if (annotations == null) { // lazy construction
|
||||
annotations = new LinkedHashMap<>((Math.max(
|
||||
annotations = LinkedHashMap.newLinkedHashMap(Math.max(
|
||||
declaredAnnotations.size(),
|
||||
Math.min(12, declaredAnnotations.size() + superAnnotations.size())
|
||||
) * 4 + 2) / 3
|
||||
)
|
||||
);
|
||||
}
|
||||
annotations.put(annotationClass, e.getValue());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue