mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 06:45:07 +02:00
8200696: Optimal initial capacity of java.lang.Class.enumConstantDirectory
Reviewed-by: dholmes, redestad
This commit is contained in:
parent
ceea439679
commit
277ac7e034
3 changed files with 141 additions and 4 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1994, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1994, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -3529,7 +3529,7 @@ public final class Class<T> implements java.io.Serializable,
|
|||
if (universe == null)
|
||||
throw new IllegalArgumentException(
|
||||
getName() + " is not an enum type");
|
||||
directory = new HashMap<>(2 * universe.length);
|
||||
directory = new HashMap<>((int)(universe.length / 0.75f) + 1);
|
||||
for (T constant : universe) {
|
||||
directory.put(((Enum<?>)constant).name(), constant);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue